Disable Child Controls Recursively
You can just use "not IsDisable" versus the IF...ELSE block. Additionally, the recursive call to ControlStatus should be done all the time so that the parent control is enabled/disabled along with the children. // to enable\disable the control & its child controls public...
You can just use "not
IsDisable
" versus the IF
...ELSE
block. Additionally, the recursive call to ControlStatus
should be done all the time so that the parent control is enabled/disabled along with the children.
// to enable\disable the control & its child controls public void ControlStatus(Control control, bool isDisable) { foreach (Control c in control.Controls) try { if (c is WebControl) ((WebControl)c).Enabled = !isDisable; if (c.HasChildren) ControlStatus(c, isDisable); } catch (Exception) { } }