注册 登录
编程论坛 ASP.NET技术论坛

如何自动添加控件?

zmidl 发布于 2010-05-19 16:22, 1092 次点击
protected void Button1_Click(object sender, EventArgs e)
{      
   for(int a=1;a<5;a++)
    {
        TextBox tb = new TextBox();
        tb.Text = "";
        tb.ID = "box" + i.ToString();
        this.form1.Controls.Add(tb);
     }
}
以上代码 让我点击按钮 显示5个textbox
我想每点击一次 按钮 增加显示一个textbox 该如何实现呢??
3 回复
#2
霹雳剑客2010-05-19 16:53
protected void Button1_Click(object sender, EventArgs e)
{      
        TextBox tb = new TextBox();
        tb.Text = "";
        this.form1.Controls.Add(tb);
}
#3
zmidl2010-05-20 17:16
楼上的你不要复制我的代码撒!!做人要踏实  骗分没意思!!!
1