coder
coder

Reputation: 4313

asp:CreateUserWizard - how to display minimum password requirement

It's not displaying the min requirement until the 'CreateUser' is clicked. How do I make it to validate the password requirement beforehand and display a message when the password field loses focus.

Upvotes: 1

Views: 92

Answers (1)

R.C
R.C

Reputation: 10565

With the default markup of CreateUserWizard control as below, you cannot have such functionality.

<asp:CreateUserWizard ID="CreateUserWizard1" runat="server">
        <WizardSteps>
            <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
            </asp:CreateUserWizardStep>
            <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
            </asp:CompleteWizardStep>
        </WizardSteps>
</asp:CreateUserWizard>

Therefore, the idea is to customize the CreateUserWizard control as per your needs. Its better to use Validators so that you can display the messages beforehand. They key is to create a <ContentTemplate> element within the <asp:CreateUserWizardStep> element.

<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
<ContentTemplate>
<table>
<tr>
<td>
Sign Up to get started</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">
User Name:</asp:Label></td>
<td>
<asp:TextBox ID="UserName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" 
     ControlToValidate="UserName" ErrorMessage="User Name is required."
     ToolTip="User Name is required." 
     ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
<tr>
<td>
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">
Password:</asp:Label></td>
<td>
<asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
     ErrorMessage="Password is required." ToolTip="Password is required."
     ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
</tr>
</ContentTemplate>
</asp:CreateUserWizardStep>

Read MSDN for a complete tutorial.

Upvotes: 1

Related Questions