遍历页面中所有的TextBox

一,用foreach:
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 = "";
    }
}

原文地址:https://www.cnblogs.com/zhangliang1988/p/2394324.html