Aspnet后台禁用页面所有控件

作者:陆金龙    发表时间:2014-12-11 23:52   


//禁用form表单内的所有控件:
 
protected void DisableAllControls()  
{  
    foreach (Control control in form1.Controls)  
    {  
        if (control is WebControl)  
        {  
            ((WebControl)control).Enabled = false;  
        }  
        else if (control is HtmlControl)  
        {  
            ((HtmlControl)control).Disabled = true;  
        }  
    }