'Method To Enable And Disable Controls Of A Web Page.
Protected Sub EnablingDisablingControls()
'Accessing Control Of A Page.
For Each ctrl As Control In Page.Controls
ChangeControlStatus(ctrl)
' If You Want To Enabled And Disabled Particular Control Then Pass Its ControlID for eg GridView.
'ChangeControlStatus(gvOrder)
Next
End Sub
' Start Code for function
Private Sub ChangeControlStatus(ByVal c As Control)
If c.Controls.Count > 0 Then
For Each ctrl As Control In c.Controls
ChangeControlStatus(ctrl)
Next
End If
' Enabling Disabling Controls.
If TypeOf c Is TextBox Then
DirectCast(c, TextBox).Enabled = False
ElseIf TypeOf c Is Button Then
DirectCast(c, Button).Enabled = False
ElseIf TypeOf c Is RadioButton Then
DirectCast(c, RadioButton).Enabled = False
ElseIf TypeOf c Is ImageButton Then
DirectCast(c, ImageButton).Enabled = False
ElseIf TypeOf c Is CheckBox Then
DirectCast(c, CheckBox).Enabled = False
ElseIf TypeOf c Is DropDownList Then
DirectCast(c, DropDownList).Enabled = False
ElseIf TypeOf c Is HyperLink Then
DirectCast(c, HyperLink).Enabled = False
End If
End Sub
' End Code for function