功能描述:把一个Form里面的控件禁用,例外的控件可通过参数控制 Codepublic static void DisableInputControl(params Control[] excludeControls) { Page page = HttpContext.Current.Handler as Page; if (page == null) return; DisableChildInputControl(page, excludeControls); } public static void DisableChildInputControl(Control control, params Control[] excludeControls) { foreach (Control child in control.Controls) { if (excludeControls.Length > 0) { bool exists = false; foreach (Control excludeControl in excludeControls) { if (excludeControl.Equals(child)) { exists = true; break; } } if (exists) continue; } if (child is TextBox) { ((TextBox)child).Enabled = false; } else if (child is Button) { ((Button)child).Enabled = false; } else if (child is DropDownList) { ((DropDownList)child).Enabled = false; } //递归 DisableChildInputControl(child, excludeControls); } } 转载于:https://www.cnblogs.com/gdut_stu/archive/2009/01/06/1370209.html