动态生成控件
for (int i = 0; i < 8; i++)
{
Lable labMy = new Lable ();
Panel1.Controls.Add(labMy);
labMy.Text = i.ToString();
labMy.ID ="lab"+ i.ToString();
}
遍历控件
foreach(Control ctl in this.Controls[1].Controls)
{
if(ctl.GetType().Name=="TextBox")
{
TextBox tb =new TextBox();
tb=(TextBox)this.FindControl(ctl.ID);
Response.Write("<script>alert('" + tb=.Text+ "的值为空。');</script>");
}
}