0
是否有可能從VB.net中的代碼隱藏CompareValidator/RequiredFieldValidator
?VB.net禁用來自代碼背後的CompareValidator
我有3個字段(下拉菜單和兩個過期選擇器)和從下拉菜單中選擇一個月我想禁用日期選擇器輸入上的驗證/要求。
任何建議非常感謝!
請注意已經嘗試過這一點,這是行不通的:
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
Alrea dy試過了。當Validator注入JS時,JS始終首先運行。 – Iladarsda
@NewUser你想用JS禁用它嗎? – freebird
不是,我寧願從代碼後面禁用它 - 因此問題的標題。另外從DD中選擇的東西的條件非常重要。 – Iladarsda