遍历页面的服务器控件

函数功能:遍历出页面所有的TextBox 和 DropDownList 将它们的Enable 设置为False

 public void SetControl(ControlCollection c)
        {
            foreach (Control item in c)
            {
                if (item.HasControls())
                {
                    SetControl(item.Controls);
                }
                if (item is TextBox)
                {
                    ((TextBox)(item)).Enabled = false;
                }
                if (item is DropDownList)
                {
                    ((DropDownList)(item)).Enabled = false;
                }
            }
        }
原文地址:https://www.cnblogs.com/allen76615519/p/2607713.html