Disable Child Controls Recursively
public void ControlStatus(Control control, bool isDisable){ foreach (Control c in control.Controls) if (c.HasControls()) ControlStatus(c, isDisable); else { WebControl wc = c as WebControl; if (wc != null) ...
public void ControlStatus(Control control, bool isDisable)
{
foreach (Control c in control.Controls)
if (c.HasControls())
ControlStatus(c, isDisable);
else
{
WebControl wc = c as WebControl;
if (wc != null)
wc.Enabled = !isDisable;
}
}
Ignoring exceptions is bad programming practice.
Use 'as
' to avoid casting c
twice.