We help IT Professionals succeed at work.

How do I validate multiple controls with the same Validator?

bemara57
bemara57 asked
on
Medium Priority
438 Views
Last Modified: 2013-11-07
I have a validator like the one below. Right now it's only validating one control, but there are many controls on the page with the same validation criteria. How do I assign it to multiple controls? Do I really need to duplicate the validator?

                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
                    ErrorMessage="Only alphanumeric  values are allowed for page names."
                    Display="None"
                    ControlToValidate="TextBoxCreatePage"
                    ValidationExpression="^[a-zA-Z][a-zA-Z0-9_]+$"
                    SetFocusOnError="True" />
Comment
Watch Question

Commented:
I don't know of anyway to do so unless you create it in the code behind and assign it to the controls on Page_Load

Explore More ContentExplore courses, solutions, and other research materials related to this topic.