Disable all controls in a div in asp.net

Can someone tell me how can I turn off all controls in a div?

The div is set to runat = "server"

Many thanks for your help.

+6
source share
2 answers

You will probably want to use the Panel element (which displays the <div> ), have the controls you want to disable contained in it, and then set the Enabled panel to false .

+17
source

Since the OP asked how to do this with a DIV with runat = "server", I thought I would add a solution for this:

 myDiv.Attributes.Add("Disabled", ""); 

The fact that the panel with Enabled = false is displayed in any case and does not require changes in your code. There is no need for an attribute value (for example, True), since the presence of the attribute itself is sufficient.

Note. To re-enable the DIV, you cannot just set the Disabled attribute to False. You must remove the alltogether attribute:

 myDiv.Attributes.Remove("Disabled"); 
+4
source

Source: https://habr.com/ru/post/910801/


All Articles