Export (0) Print
Expand All

How to: Customize the ASP.NET CreateUserWizard Control 

You can customize the contents of the CreateUserWizard control using the CreateUserWizardStep and CompleteWizardStep 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 Customizing the Appearance of ASP.NET Login Controls.)

Additionally, because the CreateUserWizard control inherits from the Wizard class, you can add your own custom steps to the CreateUserWizard control. For more information on the Wizard control, see Wizard Web Server Control Overview.

NoteNote

You can also customize the appearance of the CreateUserWizard control using themes and style properties. For details, see ASP.NET Themes and Skins Overview and the properties of the CreateUserWizard control.

To customize the CreateUserWizard steps

  1. 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>
    
  2. 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.

    NoteNote

    If your membership provider extends the MembershipProvider class 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 a CreateUserStep property that includes CheckBox controls that enable users to specify additional options.

    No code example is currently available or this language may not be supported.
  3. 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 a CompleteStep property that references the CheckBox controls from the previous example.

    No code example is currently available or this language may not be supported.
  4. Add code to reference the additional controls. For example, handling the CreatingUser event 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 the CreatedUser event that references the CheckBox controls from the previous examples and adds them to the Comment 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".)

    No code example is currently available or this language may not be supported.

To add a wizard step

  1. 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.

    No code example is currently available or this language may not be supported.
  2. Add code for your wizard step. You can handle the NextButtonClick event of the Wizard control to execute your code. The CurrentStepIndex 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 the TextBox control 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".)

    No code example is currently available or this language may not be supported.
    Security noteSecurity Note

    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 Script Exploits Overview.

Example

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.

Security noteSecurity Note

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 Script Exploits Overview.

No code example is currently available or this language may not be supported.

See Also

Community Additions

ADD
Show:
© 2014 Microsoft