I have an ASP.Net web user control that contains a TextBox and a calendar from the Ajax Control Toolkit.
When I include this user control on my page I would like it to participate in input validation (there is a required filed validator set on the TextBox inside the UC), ie. when the page is validated the content of the UC should also be validated. So I had my UC implement the IValidator interface, which worked well except that I could not set the validation group on the user control. Apparently I'm supposed to inherit from BaseValidator to do that, but I can't since I'm already inheriting UserControl.
There's got to be a way to deal with this common scenario.
ASP.NET validation controlsIt is used to compare the value of an input control against a value of another input control. It evaluates the value of an input control to check the specified range. It evaluates the value of an input control to determine whether it matches a pattern defined by a regular expression.
In simple terms, validation ensures that your website complies with the standards accepted by most web designers. That also means that it will be accessible to more people, across more web browsers and operation systems. Having an accessible website is also regarded as good web design practice.
You can reference a control within a user control by seperating the two with a dollar sign:
<asp:RequiredFieldValidator ControlToValidate="MyUserControl$ControlId" runat="server" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With