Custom Validation with client and server side functions

G

Guest

I've set up a CustomValidator control which has both a client side and server
side function associated with it. My server side function never seems to be
called as long as I have the "EnableClientScript" property set to true. As
soon as I set this property to false , my server side function is called and
works fine. From reading the help, it was my understanding that the server
side function should be called even if I have a client side script. What am
I missing?

I also read that the customValidator is not called if there is no data in
the controlToValidate (textbox for example). Do people usually just assign
two validators to the control? Is it possible to create your own custom
control , derived from a "RequiredFieldValidator" that would also call a
server side function?

Thanks for the help.
 
J

John Saunders

Andre said:
I've set up a CustomValidator control which has both a client side and
server
side function associated with it. My server side function never seems to
be
called as long as I have the "EnableClientScript" property set to true. As
soon as I set this property to false , my server side function is called
and
works fine. From reading the help, it was my understanding that the
server
side function should be called even if I have a client side script. What
am
I missing?

I also read that the customValidator is not called if there is no data in
the controlToValidate (textbox for example). Do people usually just
assign
two validators to the control? Is it possible to create your own custom
control , derived from a "RequiredFieldValidator" that would also call a
server side function?

I usually use a RequiredFieldValidator in addition to whatever other
validators I need.

John Saunders
 
S

Steve C. Orr [MVP, MCSD]

Yes, you can use more than one validator on for a control, such as the
RequiredFieldValidator and the CustomValidator.

If your client side script determines the user's data is invalid, the page
will never post back so your server side validation won't fire.
If the client side script considers the data to be valid then the page
should post back normally and your server side validatiton routine should be
fired.
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top