In some cases you need to disable controls on a page, this will help you disable various types of controls.
protected void ControlsEnabler (Control parent, bool State) { foreach (Control c in parent.Controls) { if (c is TextBox) { ((TextBox)(c)).Enabled = State; } if (c is CheckBox) { ((CheckBox)(c)).Enabled = State; } if (c is RadioButton) { ((RadioButton)(c)).Enabled = State; } if (c is Button) { ((Button)(c)).Enabled = State; } ControlsEnabler(c, State); } }
ControlsEnabler(Page, false);
Last Updated on October 26, 2015