<asp:CustomValidator > strange behavior

  • Thread starter Thread starter z. f.
  • Start date Start date
Z

z. f.

when validation fails on the server side
after a button was clicked,
must i check in the beggining of my button click server event handler that
the page is valid, or if the page is not valid my handler should not be
called ( as i thought )
?
because i see that my code is being called even when the page is not valid,
but should it?

TIA, z.
 
If I understand your question correctly, you are wondering why you have to
check Page.IsValid.

You must always check Page.IsValid or individual validator's IsValid
property for true before saving or using the data of the page. The Click
event will always be called. Internally, the button runs Page.Validate()
before your Click event runs. But it still runs your Click event, regardless
of the results of Validate().

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