How can I enable/disable an asp.net form/controls
.net-2.0, asp.net, c#
Solution
Only the controls that inherit from WebControl will have a `Enabled` property. So you could do something like this inside your loop:
var webControl = container.Form.Controls[i] as WebControl;
if(webControl != null) {
webControl.Enabled=false;
}
Problem
How can I enable/disable an asp.net form/controls selectively or entirely from code-behind? The following code is not working. Coz there is no Enabled property in this case. ``` public static void Disable(Page container) { for (int i = 0; i < container.Controls.Count; i++) { container.Form.Controls[i].Enabled = false; } } ```