在按钮上单击以添加或删除面板 [英] on button click to add or remove panels
问题描述
如何添加和删除面板/更新面板或按钮单击。
为什么我无法在点击时创建另一个带文本框的面板,这是我的代码。
// aspx
< asp:Panel ID =Panel1runat =server >
< asp:PlaceHolder ID =PlaceHolder1runat =server>
< asp:按钮ID =bn_Addrunat =server文字=添加
onclick =bn_Add_Click>
日期自:
< asp:TextBox ID =tb_dateFromrunat =server>
日期:
< asp:TextBox ID =tb_dateTorunat =server>
ID:
< asp:TextBox ID =tb_IDrunat =server>
//aspx.cs
protected void Page_Load(object sender,EventArgs e)
{
if(Session [tt]!= null)
{
Panel tt = Session [tt]作为Panel;
地方Holder1.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;
}
访问这里....
http://stackoverflow.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://stackoverflow.com/questions/13888558/removing-dynamic-controls-from-panel[^]
这篇关于在按钮上单击以添加或删除面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!