User Details Summary in CreateUserWizard

Scenario:

Say you are collecting user information via CreateUserWizard (CUW). Upon successful user creation, by default CUW will show Successful  step with a Continue button.

Now sometimes you might want to display the summary of user's info upon successful registration. So I have a sample code below to get started.

Note : I assume you know how to add new WizardSteps to CUW. If not please check out the video here, mainly starting 10th minute.

General idea:

Here is what my CreateUserWizard going to do:

Step 1: Get Name
Step 2: Get login info
Step 3: Display summary
Step 4: Success

CUW Markup:

 <asp:CreateUserWizard ID="CreateUserWizard1"
            runat="server">
            <WizardSteps>
                <asp:WizardStep runat="server" Title="Personal Info">
                    <asp:Label ID="Label1" runat="server" Text="Name"></asp:Label>
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                </asp:WizardStep>
                <asp:CreateUserWizardStep ID="CreateUserWizardStep1"
                    runat="server">
                </asp:CreateUserWizardStep>
                <asp:WizardStep runat="server" Title="Summary" OnActivate="Summary_Activate">
                    <asp:Label ID="lblSummary" runat="server" Text="Label"></asp:Label>
                </asp:WizardStep>
                <asp:CompleteWizardStep ID="CompleteWizardStep1"
                    runat="server">
                </asp:CompleteWizardStep>
            </WizardSteps>
        </asp:CreateUserWizard>

Summary_Activate method:

 public void Summary_Activate(object sender, EventArgs e)
    {
        String summary = "Name: - " + TextBox1.Text + "<br />";
        summary += "Username: - " + CreateUserWizard1.UserName + "<br />";
        lblSummary.Text = summary;
    }

Code explanation:

It is very simple code-block. The main part is OnActivate="Summary_Activate" in the summary step. When the step is Activated, I create the summary to display and display it in a Label Control.

Customization:

You can get also display the summary in CompletedStep. Also I have used a Label, but you can use any other control or formatting of the summary.

No Comments