using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace MyEcommerce
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
btnShow.Attributes.Add("onclick", "show();");
}
protected void bntAdd_Click(object sender, EventArgs e)
{
TextBox txt = new TextBox();
txt.ID = "txtMessage";
NewUpdatePanel.Controls.Add(txt);
}
}
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function show() {
var txt = document.getElementById("txtMessage");
var ans = document.getElementById("<%= txtAns.ClientID %>");
ans.value = txt.value;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<contenttemplate>
<div id="NewUpdatePanel" runat="server">
</contenttemplate></div>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<contenttemplate>
<div>
<asp:Button ID="bntAdd" runat="server" Text="Add Control"
onclick="bntAdd_Click" />
<asp:Button ID="btnShow" runat="server" Text="Show"/>
<asp:TextBox ID="txtAns" runat="server" Text="">
</div>
</contenttemplate>
</form>
</body>
</html>