Imports Microsoft.VisualBasic
Imports System.Web.UI
Imports System.Web.UI.WebControls
Public Class
DisableControls
Public Sub SetPageControlsDisabledState(ByVal MyPage As Page,
ByVal FormName As
String)
Dim objForm As HtmlForm
Dim objCtl As Control
Dim
objTextBoxCtl As TextBox
Dim
objCheckBoxCtl As CheckBox
Dim
objCheckBoxListCtl As CheckBoxList
Dim
objRadioButtonCtl As RadioButton
Dim
objRadioButtonListCtl As RadioButtonList
Dim
objDropDownListCtl As DropDownList
Dim
objButtonCtl As Button
Dim
objCalendarPopup As eWorld.UI.CalendarPopup
Dim
objNestedCtl As Control
objForm = CType(MyPage.FindControl(FormName),
HtmlForm)
For Each objCtl In
objForm.Controls
Select Case objCtl.GetType.ToString
Case
"System.Web.UI.WebControls.TextBox"
objTextBoxCtl = CType(objCtl, TextBox)
objTextBoxCtl.Enabled = 0
Case
"System.Web.UI.WebControls.DropDownList"
objDropDownListCtl = CType(objCtl, DropDownList)
objDropDownListCtl.Enabled = 0
Case
"System.Web.UI.WebControls.CheckBox"
objCheckBoxCtl = CType(objCtl, CheckBox)
objCheckBoxCtl.Enabled = 0
Case
"System.Web.UI.WebControls.CheckBoxList"
objCheckBoxListCtl = CType(objCtl, CheckBoxList)
objCheckBoxListCtl.Enabled = 0
Case
"System.Web.UI.WebControls.RadioButton"
objRadioButtonCtl = CType(objCtl, RadioButton)
objRadioButtonCtl.Enabled = 0
Case
"System.Web.UI.WebControls.RadioButtonList"
objRadioButtonListCtl = CType(objCtl, RadioButtonList)
objRadioButtonListCtl.Enabled =
0
Case
"System.Web.UI.WebControls.Button"
objButtonCtl = CType(objCtl, Button)
objButtonCtl.Enabled = 0
Case
"eWorld.UI.CalendarPopup"
objCalendarPopup = CType(objCtl, eWorld.UI.CalendarPopup)
objCalendarPopup.Enabled = 0
'A
"div" tag is causing a nest scenario on order_circuit_worksheet.aspx
'because
it has a runat=server tag making it a server control. So do a nested loop!
Case
"System.Web.UI.HtmlControls.HtmlGenericControl"
If
objCtl.HasControls Then
For
Each objNestedCtl In
objCtl.Controls
DisabledNestedControls(objNestedCtl)
Next
End
If
End Select
Next
End Sub
Public Sub DisabledNestedControls(ByVal
objNestedCtl As Control)
Dim
nestedobjTextBoxCtl As TextBox
Dim
nestedobjCheckBoxCtl As CheckBox
Dim
nestedobjCheckBoxListCtl As CheckBoxList
Dim
nestedobjRadioButtonCtl As RadioButton
Dim
nestedobjRadioButtonListCtl As RadioButtonList
Dim
nestedobjDropDownListCtl As DropDownList
Dim
nestedobjButtonCtl As Button
Dim
nestedobjCalendarPopup As
eWorld.UI.CalendarPopup
Select Case objNestedCtl.GetType.ToString
Case "System.Web.UI.WebControls.TextBox"
nestedobjTextBoxCtl = CType(objNestedCtl, TextBox)
nestedobjTextBoxCtl.Enabled = 0
Case "System.Web.UI.WebControls.DropDownList"
nestedobjDropDownListCtl = CType(objNestedCtl, DropDownList)
nestedobjDropDownListCtl.Enabled = 0
Case "System.Web.UI.WebControls.CheckBox"
nestedobjCheckBoxCtl = CType(objNestedCtl, CheckBox)
nestedobjCheckBoxCtl.Enabled = 0
Case "System.Web.UI.WebControls.CheckBoxList"
nestedobjCheckBoxListCtl = CType(objNestedCtl, CheckBoxList)
nestedobjCheckBoxListCtl.Enabled = 0
Case "System.Web.UI.WebControls.RadioButton"
nestedobjRadioButtonCtl = CType(objNestedCtl, RadioButton)
nestedobjRadioButtonCtl.Enabled = 0
Case "System.Web.UI.WebControls.RadioButtonList"
nestedobjRadioButtonListCtl = CType(objNestedCtl, RadioButtonList)
nestedobjRadioButtonListCtl.Enabled
= 0
Case "System.Web.UI.WebControls.Button"
nestedobjButtonCtl = CType(objNestedCtl, Button)
nestedobjButtonCtl.Enabled = 0
Case "eWorld.UI.CalendarPopup"
nestedobjCalendarPopup = CType(objNestedCtl, eWorld.UI.CalendarPopup)
nestedobjCalendarPopup.Enabled = 0
End Select
End Sub
End Class