Validation Question

  • Thread starter Thread starter Stefano Mostarda
  • Start date Start date
S

Stefano Mostarda

Hi there,

I have a question.

I have a webform with 2 buttons and 2 customvalidators.

I need Customvalidators to validate user input against a database.

Depending on the button I click, I want only the associated validator to
perform the check. Is there a way to know what button has been clicked
in the servervalidate event so that I can avoid the wrong validator to
check data?

Thanks in advance.
Stefano Mostarda,
Rome Italy
 
It sounds like you aren't dealing with client-side validation. That makes
your life easier.

1. Set the button's CausesValidation property to false. That will prevent
the automatic execution of Page.Validate()
2. In your Click event, call the appropriate validator's Validate() method.
Then test if all of them passed by testing the validator's IsValid property.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More",
http://www.peterblum.com/vam/home.aspx
 
Back
Top