I am using the ASP.NET CreateUserWizard as a signup form to my website. I have it working fine but I wanted to add validation to my fields. I setup asp:RequiredFIeldValidators and also asp:CustomValidators. The goal of my validators is to check each field individually and then if the text does not pass then the page will be marked as invalid and an error message will display under each invalid textbox. When I run my website and I put information to flag the validators in my website stops the page from progressing further which is correct. The problem is that my validators do not display the error message. Here is a short version of my form (I cut out all but one field so it is easier to read):
<asp:CreateUserWizard ID="CreateUser" runat="server" LoginCreatedUser="false" RequireEmail="true" DisableCreatedUser="true">
<WizardSteps>
<asp:CreateUserWizardStep runat="server">
<ContentTemplate>
<tr>
<td>
<asp:Label ID="FirstNameLabel" runat="server" AssociatedControlID="FirstName">First Name: </asp:Label>
</td>
<td>
<asp:TextBox ID="FirstName" runat="server" /><asp:Label ID="lblFirstName" runat="server" />
<asp:RequiredFieldValidator ID="FirstNameRequired" runat="server" ControlToValidate="FirstName" ErrorMessage="Your first name is required." ToolTip="Your first name is required." ValidationGroup="CreateUserVal">*</asp:RequiredFieldValidator>
<asp:Literal runat="server" EnableViewState="false" ID="LiteralFirstNameError"></asp:Literal>
<asp:CustomValidator ValidationGroup="val1" runat="server" ID="ValidaterFirstNameCheck" ControlToValidate="FirstName" OnServerValidate="ValidateFirstName" ErrorMessage="Error!" />
</td>
</tr>
A email has been sent to your mailbox. Please follow the instructions in the email to ac开发者_StackOverflow中文版tivate your account.
Any help is appreciated. Thanks in advance.
To display the error message you have to remove the * in RequiredFieldValidator.
精彩评论