That means you can simply put the validator where you want it, attach it to the Drop Down List object in the User Control and it will work. I ended up adding the to my user control as Teemu suggested. From the documentation it looks like -as you say- this should not be possible so I imagine its a nasty hack. I learned one special case since writing my earlier post. While its typical to have that special character as a $, you have it working with a :.
However, when I am creating my validation controls, dd Something is not an option when selecting which control to validate. You probably will make the Drop Down List field Public so it can be seen once you typecast the User Control object to the class of that User Control. Like Teemu said, its possible to use the Validation Property Attribute.
I tried using it anyways, and here is the error I get: Control 'dd Something' referenced by the Control To Validate property of 'vld Something' cannot be validated. You need to add a property to your usercontrol that returns a string value of the data.
The problem is described in this post, basically it can be summarized in â€œyou have a user control with validators, you put more than one instance of the user control in a page, all validators are fired togetherâ€The above post already gives a solution, but is not a general one.
I want to avoid the need to go into the user control and tweak with validators, so I came up with this little solution The function Assign Validation Group accepts a Control, then it iterates recursively into inner controls, and for each control that descends from Base Validator, it assign a group name based on the id of the root control.
In this case, we use the Less Than operator, because we wish for the first control to have the smallest value.
We set the type to integer, because we want to compare integers.
For instance, it would be possible to enter nothing, or enter a piece of text instead of a number.
You should always consider this when using the Compare Validator.
It might seem a bit overwhelming, but it's actually quite simple.