且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在按钮上单击以添加或删除面板

更新时间:2023-11-30 16:00:46

访问这里....



http://***.com/questions/13888558/removing-dynamic-controls -from-panel [ ^

How do I add and remove panel / updatepanels or button click.

Why I couldn't create another panel with textbox on click, here is my code.

//aspx

<asp:Panel ID="Panel1" runat="server">
<asp:PlaceHolder ID="PlaceHolder1" runat="server">


<asp:Button ID="bn_Add" runat="server" Text="Add"
onclick="bn_Add_Click">




Date From :
<asp:TextBox ID="tb_dateFrom" runat="server">


Date To:
<asp:TextBox ID="tb_dateTo" runat="server">


ID:
<asp:TextBox ID="tb_ID" runat="server">


//aspx.cs

protected void Page_Load(object sender, EventArgs e)
{
if (Session["tt"] != null)
{
Panel tt = Session["tt"] as Panel;
PlaceHolder1.Controls.Add(tt);
}
}

protected void bn_Add_Click(object sender, EventArgs e)
{
Panel tt = new Panel();
TextBox tb = new TextBox();
tb_dateFrom.Text = "";
tb_dateTo.Text = "";
tb_ID.Text = "";
tt.Controls.Add(tb);
PlaceHolder1.Controls.Add(tt);
PlaceHolder1.Controls.Add(tt);
Session["tt"] = tt;
}

visit here....

http://***.com/questions/13888558/removing-dynamic-controls-from-panel[^]