I know this has been asked a lot, but I have a server-side custom validator that is not being fired, and I cannot find why (also, I’ve copied examples that work from other places and cannot make it work…)
The code:
<asp:CustomValidator ID="MyValidator" runat="server" ErrorMessage="My error message" OnServerValidate="MyValidator_OnServerValidate" />
Validate function
Protected Sub MyValidator_OnServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles MyValidator.ServerValidate
Dim i As Integer
i = 0
args.IsValid = False
End Sub
This is the last test I’m doing (copied from other question), but I’ve also tried attaching the validator to one control (and adding the ValidateEmptyText) and removing the handles MyValidator.ServerValidate and adding it to the tag with onServerValidate.
(I’m usually a Java programmer, so it can be a very basic error I should have seen, don’t underestimate my .Net ignorance)
Thanks in advance
EDIT: Add the code for the submit button…
<asp:Button ID="lbGuardar" runat="server" CssClass="button" Text="Guardar" CausesValidation="true" ></asp:Button>
EDIT 2: Added a Page.validate() on my button code, and it does not call the server side of the validator. Also, the custom validator is being called (at least the client/javascript side of it, but not the server side)
Did not manage to make it work. Removed custom validator, and made validations inside the logic.