Click here to Skip to main content
15,918,168 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
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;
}
Posted
Updated 3-Feb-14 2:58am
v2
Comments
Kornfeld Eliyahu Peter 3-Feb-14 8:06am    
Have you done anything so far? Show some effort (code or searching)! As is it ain't a question...

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900