How do I disable all controls in ASP.NET page?

Posted by Mohamed on Stack Overflow See other posts from Stack Overflow or by Mohamed
Published on 2009-02-02T23:01:12Z Indexed on 2010/04/03 4:13 UTC
Read the original article Hit count: 404

Filed under:
|
|

I have multiple dropdownlist in a page and would like to disable all if user selects a checkbox which reads disable all. So far I have this code and it is not working. Any suggestions?

foreach (Control c in this.Page.Controls)
{
    if (c is DropDownList)
        ((DropDownList)(c)).Enabled = false;
}

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about asp.net-controls