public static void DisableControls(Control parent) { foreach (Control c in parent.Controls) { if (c is TextBox) { TextBox d = (TextBox)c; d.Enabled = false; } else if (c is DropDownList) { DropDownList d = (DropDownList)c; d.Enabled = false; } else if (c is DateDropDown) { DateDropDown d = (DateDropDown)c; d.Enabled = false; } else if (c is CheckBoxList) { CheckBoxList d = (CheckBoxList)c; foreach (ListItem f in d.Items) { f.Enabled = false; } } else if (c is TrueFalseDropDown) { TrueFalseDropDown d = (TrueFalseDropDown)c; d.Enabled = false; } else if (c is DivisionDD) { DivisionDD d = (DivisionDD)c; d.Enabled = false; } DisableControls(c); } }
public static void ClearControls(Control o) { foreach (Control c in o.Controls) { if (c is TextBox) { TextBox d = (TextBox)c; d.Text = String.Empty; } else if (c is DropDownList) { DropDownList d = (DropDownList)c; d.SelectedIndex = 0; } else if (c is DateDropDown) { DateDropDown d = (DateDropDown)c; d.ClearItems(); } else if (c is CheckBoxList) { CheckBoxList d = (CheckBoxList)c; foreach (ListItem f in d.Items) { f.Selected = false; } } else if (c is TrueFalseDropDown) { TrueFalseDropDown d = (TrueFalseDropDown)c; d.Clear(); } else if (c is DivisionDD) { DivisionDD d = (DivisionDD)c; d.Clear(); } } }