CustomValidator

James

Well-known member
Joined
Oct 3, 2002
Messages
78
I have a CustomValidator, requiredFieldValidator and validationSummary control on my web form. The requiredFieldValidator displays a messagebox when the validation fails. However, my customValidator doesnt display a messagebox when if fails. I did not change the properties of the validationSummary control. And my CustomValidator control looks to have its properties set correctly. Can someone help?

CustomValidator code behind"

Sub CusValJan3_ServerValidate(ByVal source As System.Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs)
Dim strValue As String
strValue = args.Value

If strValue = "0" Or strValue = TotEst.Text Then
args.IsValid = True
Else
args.IsValid = False
End If

End Sub

James
 
Strange CustomValidator

Initially, I found the same pb as you, about CustomValidator: no events fired. Finally, it works if i put :

ControlToValidate=""

in the asp part like:

<asp:CustomValidator id="chargeValidator" runat="server" Enabled="true" ControlToValidate="" ErrorMessage="Charge estimate value" OnServerValidate="chargeValidator_ServerValidate" Display="Static">*</asp:CustomValidator></TD>

After you can put all the code you want in

chargeValidator_ServerValidate(...)
 
Back
Top