I put CustomValidator in my form. I have not set the ControlToValidate property. In my ServerValidate event, I wrote the following:
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args) { args.IsValid = false; }
I set a breakpoint on this method, but it doesn't seem to be happening. But if I do it in a different form, it works like a charm.
- The
ValidationGroup property of both the button and CustomValidator same - I tried to remove this property both in the button and in
CustomValidator , it still does not work.
There seems to be something in common. I just put CustomValidator on the form and do not touch any of its properties, except how to simply set my ServerValidate event ServerValidate .
EDIT: here is the aspx part:
<asp:CustomValidator ID="CustomValidator2" runat="server" ErrorMessage="This is a test" onservervalidate="CustomValidator1_ServerValidate" ValidationGroup="PA"></asp:CustomValidator> <asp:Button ID="btnPensionersOK" runat="server" Text="OK" Width="75px" onclick="Button1_Click" ValidationGroup="PA" />
Mikayil abdullayev
source share