Can a Compare validator fire when either of two controls changes?
-
From what I have read, a Compare validator only fires when the ControlToValidate changes (not the ControlToCompare). How can I get a validator that fires when either of two controls change?
-
From what I have read, a Compare validator only fires when the ControlToValidate changes (not the ControlToCompare). How can I get a validator that fires when either of two controls change?
You question is looking Good. You can go for custom validator or try using two compare validator for both the controls.
Cheers!! Brij Microsoft MVP ASP.NET/IIS Visit my Blog: http://brijbhushan.net
-
From what I have read, a Compare validator only fires when the ControlToValidate changes (not the ControlToCompare). How can I get a validator that fires when either of two controls change?
-
From what I have read, a Compare validator only fires when the ControlToValidate changes (not the ControlToCompare). How can I get a validator that fires when either of two controls change?
Yes, that is one of it's intended uses. you need to set the
ControlToValidate
andControlToCompare
to the ID of the controls you want to compare. There is documentation on it here[^], the main things you need to set are theType
property (seeh here[^]) and the Operator property (see here[^]) as well as the various display stuffm such as the error message. It is possible to have more complex validation of controls, but you need to hand-roll your own JavaScript and Code-behind. [Edit] Totally misread your question, sorry! I think it validates of either is changed, but you've sown the seed of doubt in my mind! It wouldn't make sense to validate on only one control...Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^] -
You question is looking Good. You can go for custom validator or try using two compare validator for both the controls.
Cheers!! Brij Microsoft MVP ASP.NET/IIS Visit my Blog: http://brijbhushan.net
Thanks for the answer. I ended up programing it with two custom validators. When I entered the one I would clear the message (if there was one) of the other.