private void DisableChildControl(Control c) { if (c is TextBox) { (c as TextBox).Enabled = false; } if (c is DropDownList) { (c as DropDownList).Enabled = false; } if (c is DateTimeControl) { (c as DateTimeControl).Enabled = false; } if (c.HasControls()) { foreach (Control ctl in c.Controls) { DisableChildControl(ctl); } } } private void DisableTextBoxs() { try { foreach (Control cp in Page.Controls) { DisableChildControl(cp); } } catch (Exception ex) { string sMessage = ex.Message; } }
遍历控件