对页面所有TextBox进行操作

private void ClearAllText(System.Web.UI.Control contrl)
{
    int ctl_count=contrl.Controls.Count;
    for (int i=0;i<ctl_count;i++)
    {
        foreach(Control ctl in contrl.Controls[i].Controls)
        {
            if (ctl.HasControls())
            {
                ClearAllText(ctl.Parent);
            }
            else
            {
                if (ctl is TextBox)
                    (ctl as TextBox).Text="";
            }
        }
    }
}

在页面中添加一个按钮,调用此函数,参数为this.Page,如:

ClearAllText(this.Page);
原文地址:https://www.cnblogs.com/CoderWayne/p/4485563.html