Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foreach (Control c in this.Page.Controls)
- {
- if (c is DropDownList)
- ((DropDownList)(c)).Enabled = false;
- }
- protected void DisableControls(Control parent) {
- foreach(Control c in parent.Controls) {
- if (c is DropDownList) {
- ((DropDownList)(c)).Enabled = false;
- }
- DisableControls(c);
- }
- }
- protected void Event_Name(...) {
- DisableControls(Page); // use whatever top-most control has all the dropdowns or just the page control
- }
- For Each c As Control In parentControl.Controls
- If TypeOf (c) Is CheckBox Then
- CType(c, CheckBox).Enabled = enable
- ElseIf TypeOf (c) Is RadioButtonList Then
- CType(c, RadioButtonList).Enabled = enable
- End If
- SetControls(c)
- Next
- End Sub
- protected void Page_Load(object sender, EventArgs e)
- {
- DisableChilds(this.Page);
- }
- private void DisableChilds(Control ctrl)
- {
- foreach (Control c in ctrl.Controls)
- {
- DisableChilds(c);
- if (c is DropDownList)
- {
- ((DropDownList)(c)).Enabled = false;
- }
- }
- }
- <body>
- <form id="form1" runat="server">
- ...
- </form>
- </body>
- protected void Page_Load(object sender, EventArgs e)
- {
- form1.Disabled = true;
- }
Add Comment
Please, Sign In to add comment