- C# code
protected void Page_Load(object sender, EventArgs e) { TextBox tb = new TextBox(); tb.Text = "sss"; this.AddedControl(tb,2); }
请问我如何将它添加进页面显示?
------解决方案--------------------------------------------------------
在你的页面上定义一个panel
<Asp:panel id="Pnl1"></Asp:panel>
然后,你的后台就可以为之添加控件了:
protected void Page_Load(object sender, EventArgs e)
{
TextBox tb = new TextBox();
tb.Text = "sss";
Pnl1.Controls.Add(tb);
}
------解决方案--------------------------------------------------------
不一定用panel!!
最简洁的代码是:
TextBox tb = new TextBox();
tb.Text = "sss";
this.form1.Controls.Add(tb);