遍历页面全部控件方法
时间:2011-01-19 来源:烈日轨迹
foreach(Control cl in this.Page.FindControl("Form1").Controls)
{
if(cl.GetType().ToString()=="System.Web.UI.WebControls.TextBox")
{
((TextBox)cl).Text="";
}
}
二,用for循环内foreach:
for (int i = 0; i < this.Controls.Count; i++)
{
foreach (System.Web.UI.Control control in this.Controls[i].Controls )
{
if (control is TextBox)
(control as TextBox).Text = "";
}
}
相关阅读 更多 +