BaseValidator Inherited Ctrl Not working with RequiredFieldValidator

J

James

Hi All,

I have written a control that inherits BaseValidator. If it used by
itself on a page, the control works perfectly fine.

If I drop the RequiredFieldValidator on the same page to evaluate a
different textbox, my control does not work. But *only* if
RequiredFieldValidator does not pass.

It seems like when RequiredFieldValidator raises False, it shuts
everything else off.

I placed a breakpoint in my control, and it doesn't even go into it.

Any suggestions are greatly appreciated!

Thanks!!
James
 
J

James

Well, after I placed this post, I tried changing "Enable Client Script"
to FALSE on the RequiredFieldValidator control.

This allowed my control to work properly!

I'm not using client side scripting, so this not an issue. But it
would seem strange that this would have to be the case.

Perhaps somebody could explain why this would need to be done?

Thanks!
James
 
T

Teemu Keiski

Hi,

at client if RequiredFieldValidator fails, that already prevents the page
from posting back (since one of the validators indicates error).

It is so that if your control has no input/selection whatsoever,
RequiredFieldValidator is the one catching that, and no other validators
will be yet invoked (e.g by default no other validator than RFV is applied
for empty input). Then if there is some input, RFV will pass validation, and
other, more specialized validators kick in, like check the correctness of
the given input, as the input now exists.

Mechanically it happens so that if validation control is passed empty input
value, it returns true as outcome of the validation. This way, it's left up
to the RFV in the first place to check for empty inputs.

You can tweak this behaviour with custom validators / 3rd party validator
controls & components (Professional Validation And More for instance)
 

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,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top