CustomValidator Control

G

Guest

Hi,
I have a TextBox, Button and CustomValidator web controls on an aspx page.
When a user clicks the Button, I want to perform server side validation of
the textbox with the method specified in the CustomValidator control.
When the validation fails, I'm setting the args.IsValid=false; so it will
display the message on the page, but the application does not stop and
continues and executes the Button click EventHandler.
How can I stop the execution of the page after the validation fails?
Thank you.
 
S

Scott Allen

It's one of those unfortunate quirks that client side validation will
stop a client's POST operation dead in it's tracks, but server side
validation requires your code to explicitly check Page.IsValid and
branch away from the typical flow of execution.

In other words, you probably want to wrap your logic in the button
click event with:

if(Page.IsValid)
{

}
 

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

Top