By using this code below, I will be able to disable the not only the children of the page but also controls that are children of controls that are children of the page
Private Sub DisableChildControls(controls As ControlCollection)
For Each ctrl As Control In controls
If TypeOf ctl Is TextBox Then
DirectCast(ctl, TextBox).Enabled = False
ElseIf TypeOf ctl Is Button Then
DirectCast(ctl, Button).Enabled = False
ElseIf TypeOf ctl Is RadioButton Then
DirectCast(ctl, RadioButton).Enabled = False
ElseIf TypeOf ctl Is RadioButtonList Then
DirectCast(ctl, RadioButtonList).Enabled = False
ElseIf TypeOf ctl Is CheckBox Then
DirectCast(ctl, CheckBox).Enabled = False
ElseIf TypeOf ctl Is CheckBoxList Then
DirectCast(ctl, CheckBoxList).Enabled = False
ElseIf TypeOf ctl Is DropDownList Then
DirectCast(ctl, DropDownList).Enabled = False
ElseIf TypeOf ctl Is ListBox Then
DirectCast(ctl, ListBox).Attributes.Add("disabled", "disabled")
End If
If ctrl.Controls.Count > 0 Then
DisableChildControls(ctrl.Controls)
End If
Next
End Sub
In the desired event, I call the traversal using:
If Me.Controls.Count > 0 Then
DisableChildControls(Me.Controls)
End If