Custom Validator Event Executes but does stop or disaplay error

N

NRao

Hello,

I am using a custom validator control and wanted to validate server side and
do not have client side validation function. The server side event executes
but does not stop the page or does not display the error.

<asp:CustomValidator id="custWDEndDate" runat="server"
ControlToValidate="txtPickupDate" ErrorMessage="Not
Valid" EnableClientScript="False"
OnServerValidate="custWDEndDate_ServerValidate"></asp:CustomValidator>

protected void custWDEndDate_ServerValidate(object source,
System.Web.UI.WebControls.ServerValidateEventArgs args)
{
args.IsValid = false;
}


Any ideas
 
J

John Saunders

NRao said:
Hello,

I am using a custom validator control and wanted to validate server side
and
do not have client side validation function. The server side event
executes
but does not stop the page or does not display the error.

<asp:CustomValidator id="custWDEndDate" runat="server"
ControlToValidate="txtPickupDate" ErrorMessage="Not
Valid" EnableClientScript="False"
OnServerValidate="custWDEndDate_ServerValidate"></asp:CustomValidator>

protected void custWDEndDate_ServerValidate(object source,
System.Web.UI.WebControls.ServerValidateEventArgs args)
{
args.IsValid = false;
}

It's not meant to stop the page or display an error. You're meant to check
Page.IsValid and then decide what you want to do if the page is not valid.

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top