How to: Customize the ASP.NET CreateUserWizard Control
You can customize the contents of thecontrol using the and templates. By specifying the contents of the templates, you can specify your own custom user interface (UI) that includes controls that the CreateUserWizard control uses to gather information about the new user, as well as additional controls that you specify (for a list of the controls that the CreateUserWizard control uses, see .)
Additionally, because the CreateUserWizard control inherits from theclass, you can add your own custom steps to the CreateUserWizard control. For more information on the Wizard control, see .
You can also customize the appearance of the CreateUserWizard control using themes and style properties. For details, seeand the properties of the CreateUserWizard control.
To customize the CreateUserWizard steps
Place a CreateUserWizard control on your page using the following syntax.
<asp:CreateUserWizard ID="CreateUserWizard1" Runat="server"> <WizardSteps> <asp:CreateUserWizardStep runat="server"> </asp:CreateUserWizardStep> <asp:CompleteWizardStep runat="server"> </asp:CompleteWizardStep> </WizardSteps> </asp:CreateUserWizard>
To customize the user account creation step, create a <ContentTemplate> element within the <asp:CreateUserWizardStep> element. Inside the template, add markup and controls to define the layout and content of the UI for gathering the user information you need.
If your membership provider extends theclass with custom members, you must add any controls to gather custom information required by your membership provider for creating a new user. For details, see CreateUserWizardStep.
The following code example shows aproperty that includes controls that enable users to specify additional options.
To customize the completion step, create a <ContentTemplate> element within the <asp:CompleteWizardStep> element. Inside the template, add markup and controls to define the layout and content of the UI for displaying a confirmation message and optionally allowing the user to navigate to continue. (You must provide the controls to gather the information required by your membership provider for creating a new user account. For details, see CompleteWizardStep.)
The following code example shows aproperty that references the CheckBox controls from the previous example.
Add code to reference the additional controls. For example, handling theevent enables you to enter code to gather, verify, and modify information before a new user account is created.
The following code example shows a handler for theevent that references the CheckBox controls from the previous examples and adds them to the property of the newly created user account. You will need to add an OnCreatedUser attribute to the CreateUserWizard control on your page that references the handler for the CreatedUser event (for example, OnCreatedUser="CreateUserWizard1_CreatedUser".)
To add a wizard step
Add an <asp:WizardStep> element to the <WizardSteps> section of the CreateUserWizard control. Include any controls and markup in the additional wizard step that your customized CreateUserWizard control will use.
For example, the following code example shows a step to be added before the CreateUserStep of the CreateUserWizard control that includes a textbox control for users to enter a user name. The user name will be checked to ensure that it does not already exist in the membership database.
Add code for your wizard step. You can handle theevent of the Wizard control to execute your code. The property value indicates which additional wizard step raised the NextButtonClick event by the step index number (starting from 0 for the first step).
The following code example shows a handler for the NextButtonClick event that takes the user name entered in thecontrol in the wizard step from the previous code example and verifies that the user name is not blank and does not currently exist in the membership database. You will need to add an OnNextButtonClick attribute to the CreateUserWizard control on your page that references the handler for the NextButtonClick event handler (for example, OnNextButtonClick="CreateUserWizard1_NextButtonClick".)
This control has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate user input to ensure that the input does not contain HTML elements or script. For more information, see.
The following code example shows a CreateUserWizard control with templates defined for the two basic steps, CreateUserStep and CompleteStep, and an additional wizard step added before the CreateUserStep.
This control has a textbox that accepts user input, which is a potential security threat. User input in a Web page can potentially contain malicious client script. By default, ASP.NET Web pages validate user input to ensure that the input does not contain HTML elements or script. As long as this validation is enabled, you do not need to explicitly check for script or HTML elements in user input. For more information, see.