1
下面是自定義的驗證碼定製驗證不工作(VB .NET)
<asp:CustomValidator ID="ModelValidator" runat="server"
ErrorMessage="Model is required."
ForeColor="Red" ValidateEmptyText="true"
OnServerValidate="Model_Validate" ></asp:CustomValidator>
代碼
Protected Sub Model_Validate(source As Object, args As ServerValidateEventArgs) Handles ModelValidator.ServerValidate
Dim value As String = txtModel.SelectedItem.Text
If value = "--None--" Then
args.IsValid = False
End If
End Sub
做了那個已經還沒有拋出任何錯誤的 –
你設置了控件的屬性來驗證嗎? –
我已經做到了,謝謝 –