现在可以点一下button1就能多生成一个textbox了,我想在点了button2后,把这些textbox里的值显示出来,请问下面的BUTTON2里的代码该如何写,多谢了~~~
static int n = 1;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < n; i++)
{
TextBox txtbx = new TextBox();
txtbx.ID = "txtbx" + i.ToString();
PlaceHolder1.Controls.Add(txtbx);
}
n++;
}
protected void Button2_Click(object sender, EventArgs e)
{
for (int i = 0; i < n; i++)
{
TextBox ttb = new TextBox();
ttb.ID = "txtbx" + i.ToString();
Response.Write(ttb.Text);
}
}
------解决方案--------------------------------------------------------
- C# code
foreach(Control txt in this.PlaceHolder1.Contols{ if(txt is TextBox){ Response.Write(((TextBox)txt).Text);}}
------解决方案--------------------------------------------------------
Button1_Click(null,null);
厄...请问这句是啥意思?为啥要加NULL,NULL...
---------------------
textbox must first be created, this is to invoke button1_click function.