CompareValidator / RequiredFieldValidator
是否可以从 VB.net 中的代码中禁用?
我有 3 个字段(下拉列表和两个日期选择器),一旦选择了下拉列表中的月份,我想禁用验证/需要 datepicker 输入。
任何建议都非常感谢!
请注意已经尝试过,但它不起作用:
Protected Sub DashbodropardMonthsDropDown_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DashbodropardMonthsDropDown.SelectedIndexChanged
' If Month is selected from DD menu
Dim MonthDD As Integer = DashbodropardMonthsDropDown.SelectedValue
' If nothing selected or selected "--select" with value 0
If MonthDD = 0 Then
'Validate DatePicker
CompareValidatorT1.Enabled = True
RequiredFieldValidator2.Enabled = True
RequiredFieldValidator1.Enabled = True
Else
'Do Not Validate DatePicker
CompareValidatorT1.Enabled = False
RequiredFieldValidator2.Enabled = False
RequiredFieldValidator1.Enabled = False
End If
End Sub