Validation across user controls?

G

Guest

Hi,

Does anyone know if it's possible to do validation across 2 different user
controls?

I have a custom datepicker control in the first user control and several
datapicker controls in a second user control. I want to (client side) make
sure the user cannot select a date in the second user control that exceeds
the date selected in the first user control... any ideas?
 
P

Peter Blum

The ControlToValidate property on validators is limited to controls in the
same "naming container". Each user control is its own naming container. So
you cannot use the existing validation controls, like the CompareValidator,
to validate your datepickers across user controls.

The suggestion to write a custom validator is good because you can find a
way to retrieve the values of both textboxes in your own code. Of course,
you also have to consider client-side validation. Either disregard it or
write it. (Comparing dates isn't the easiest thing to do. I have a
commercial date picker with validators [Peter's Date Package
http://www.peterblum.com/datecontrols/home.aspx]. So I've gone through
this. )

Another solution is to use a better validator control that allows controls
in various naming containers. I am also the author of such a suite of
controls: Professional Validation And More
(http://www.peterblum.com/vam/home.aspx). My 22 validators allow referencing
controls in other naming containers. They also support client-side
validation on many more browsers.

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

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

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top