I have multiple dropdownlist in a page and would like to disable all if user selects a checkbox which reads disable all. So far I have this code and it is not working. Any s
Here's a VB.NET version which also takes an optional parameter so it can be used for enabling the controls as well.
Private Sub SetControls(ByVal parentControl As Control, Optional ByVal enable As Boolean = False)
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