Validation across user controls?

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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
 
Back
Top