Monday 8 September 2008

Recursive function through controls



///
/// Recursive loop through form controls.
///

private void SetFormDisabled (Control control)
{
foreach (Control ctrl in control.Controls)
{
if (ctrl is TextBox)
{
((TextBox)(ctrl)).Enabled = false;
}
else if (ctrl is Telerik.WebControls.RadNumericTextBox)
{
((Telerik.WebControls.RadNumericTextBox)(ctrl)).Enabled = false;
}
else if (ctrl is CheckBox)
{
((CheckBox)(ctrl)).Enabled = false;
}
else
{
if (ctrl.Controls.Count > 0)
{
SetFormDisabled (ctrl);
}
}
}
}

No comments: