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

后端 未结 9 1663
旧时难觅i
旧时难觅i 2020-12-14 08:17

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 s

9条回答
  •  悲&欢浪女
    2020-12-14 08:58

    If you really want to disable all controls on a page, then the easiest way to do this is to set the form's Disabled property to true.

    ASPX:

    
        
    ...

    Code-behind:

    protected void Page_Load(object sender, EventArgs e)
    {
        form1.Disabled = true;
    }
    

    But of course, this will also disable your checkbox, so you won't be able to click the checkbox to re-enable the controls.

提交回复
热议问题