- CreateUserWizard Web Server Control
in ASP.NET environment,This article describes you how to work with CreateUserWizard
Web Control. The user interface of MembershipProvider provided by this Control that
can be communicating with your Web site's user data store to create new user accounts
in the data store. The CreateUserWizard contains the ability to create the user
and disable the user on MembershiProvider if necessary.
By default, the CreateUserWizard control will accept a user name and password from
the Web site visitor. Based on the requirements of the site's MembershipProvider
object, the CreateUserWizard control will optionally accept an e-mail address, represented
by the Email property, and a password recovery confirmation question and answer,
represented by Question and Answer. For a table showing all required and optional
controls for CreateUserWizard, see CreateUserStep.
User Creation
To create the user, must satisfy the following,
- Create a password if AutoGeneratePassword is set to true.
- Create the user in the data store that the MembershipProvider represents.
- Disable the user in the store if the DisableCreatedUser property is set to true.
Styles
- ContinueButtonStyle - Continue button.
- CreateUserButtonStyle -Create User button.
- HyperLinkStyle - Links to other pages.
- InstructionTextStyle -Instructional text on the page that tells users how
to use the control.
- LabelStyle -Labels for all input fields, such as text boxes.
- TextBoxStyle -Text entry input fields.
- TitleTextStyle -Title text for each view.
- CompleteSuccessTextStyle -Text displayed to the user when the password recovery
or reset attempt is successful.
- ErrorMessageStyle -Error messages when the membership provider fails to create
a new user account.
- TextBoxStyle -Text entry input fields.
- PasswordHintStyle -The text that describes password requirements.
- ValidatorTextStyle -Error messages associated with validation.
The following code snippets explains how to work with the CreateUserWizard control
-
<html>
<head id="Head1" runat="server">
<title>CreateUserWizard Sample</title>
</head>
<body>
<form id="form2" runat="server">
<div>
<asp:CreateUserWizard ID="Createuserwizard1" runat="server">
<WizardSteps>
<asp:CreateUserWizardStep ID="Createuserwizardstep1" runat="server"
Title="Sign Up for Your New Account">
lt;ContentTemplate>
<table border="0">
<tr>
<td>
<table border="0" style="height: 100%; width: 100%;">
<tr>
<td align="center" colspan="2">
Sign Up for Your New Account</td>
</tr>
<tr>
<td align="right">
<asp:Label runat="server" AssociatedControlID="UserName" ID="UserNameLabel">
User Name:</asp:Label></td>
<td>
<asp:TextBox runat="server" ID="UserName"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="UserName"
ToolTip="User Name is required."
ID="UserNameRequired" ValidationGroup="Createuserwizard1"
ErrorMessage="User Name is required.">
*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label runat="server" AssociatedControlID="Password"
ID="PasswordLabel">
Password:</asp:Label></td>
<td>
<asp:TextBox runat="server" TextMode="Password" ID="Password"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="Password"
ToolTip="Password is required."
ID="PasswordRequired" ValidationGroup="Createuserwizard1"
ErrorMessage="Password is required.">
*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label runat="server" AssociatedControlID="ConfirmPassword"
ID="ConfirmPasswordLabel"> Confirm Password:</asp:Label></td>
<td>
<asp:TextBox runat="server" TextMode="Password" ID="ConfirmPassword"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="ConfirmPassword"
ToolTip="Confirm Password is required."
ID="ConfirmPasswordRequired" ValidationGroup="Createuserwizard1"
ErrorMessage="Confirm Password is required.">
*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label runat="server" AssociatedControlID="Email" ID="EmailLabel">
Email:</asp:Label></td>
<td>
<asp:TextBox runat="server" ID="Email"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="Email"
ToolTip="Email is required."
ID="EmailRequired" ValidationGroup="Createuserwizard1"
ErrorMessage="Email is required.">
*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label runat="server" AssociatedControlID="Question" ID="QuestionLabel">
Security Question:</asp:Label></td>
<td>
<asp:TextBox runat="server" ID="Question"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="Question"
ToolTip="Security question is required."
ID="QuestionRequired" ValidationGroup="Createuserwizard1"
ErrorMessage="Security question is required.">
*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label runat="server" AssociatedControlID="Answer" ID="AnswerLabel">
Security Answer:</asp:Label></td>
<td>
<asp:TextBox runat="server" ID="Answer"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="Answer"
ToolTip="Security answer is required."
ID="AnswerRequired" ValidationGroup="Createuserwizard1"
ErrorMessage="Security answer is required.">
*</asp:RequiredFieldValidator>
</td>
</tr>
lt;tr>
<td align="center" colspan="2">
<asp:CompareValidator runat="server" Display="Dynamic"
ErrorMessage="The Password and Confirmation Password must match."
ControlToCompare="ConfirmPassword" ControlToValidate="Password"
ID="PasswordCompare"
ValidationGroup="Createuserwizard1">
</asp:CompareValidator>
</td>
</tr>
<tr>
<td align="center" colspan="2" style="color: Red;">
<asp:Literal runat="server" EnableViewState="False" ID="FailureText">
</asp:Literal>
</td>
</tr>
</table>
</td>
</tr>
</table>
</ContentTemplate>
</asp:CreateUserWizardStep>
<asp:CompleteWizardStep ID="Completewizardstep1" runat="server" Title="Complete">
<ContentTemplate>
<table border="0">
<tr>
<td>
<table border="0" style="height: 100%; width: 100%;">
<tr>
<td align="center" colspan="2">
Complete</td>
</tr>
<tr>
<td>
Your account has been successfully created.</td>
</tr>
<tr>
<td align="right" colspan="2">
<asp:Button runat="server" ValidationGroup="Createuserwizard1"
CommandName="Continue" ID="ContinueButton" CausesValidation=
"False" Text="Continue" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</ContentTemplate>
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
</div>
</form>
</body>
</html>
-
The follwoing code snippets explains that work with the CreatedUser event to store
the user's first and last name in personalization properties. It requires the following
codes in the Web.config file.
in web.config file,
-
<configuration>
<system.web>
<profile>
<properties>
<add name="lastName" />
<add name="firstName" />
</properties>
</profile>
</system.web>
</configuration>
-
in .aspx.cs page,
-
void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
Profile.SetPropertyValue("UserName",firstName.Text + " " + lastName.Text);
}
-
in .aspx file
-
<html>
<head id="Head1" runat="server">
<title>
CreateUserWizard.CreatedUser sample</title>
</head>
<body>
<form id="form2" runat="server">
<div>
lt;asp:createuserwizard id="CreateUserWizard1" runat="server">
lt;wizardsteps>
<asp:wizardstep ID="Wizardstep1" runat="server" steptype="Start"
title="Identification">
Tell us your name:<br />
<table width="100%">
<tr>
<td>
First name:</td>
<td>
<asp:textbox id="firstName" runat="server" /></td>
</tr>
<tr>
<td>
Last name:</td>
<td>
<asp:textbox id="lastName" runat="server" /></td>
</tr>
</table>
</asp:wizardstep>
<asp:createuserwizardstep ID="Createuserwizardstep1" runat="server"
title="Sign Up for Your New Account">
</asp:createuserwizardstep>
</wizardsteps>
</asp:createuserwizard>
</div>
</form>
</body>
</html>
-
- Related Links
-
8c3a9e1f-1b7a-4268-a86b-4d003a574c95|0|.0