Help with CreateUserWizard Control

Hi all,

I have the following CreateUserWizard control

    <h2>Create a New User Account</h2>
    <asp:CreateUserWizard ID="RegisterUser" runat="server" 
            <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
            <asp:WizardStep ID="SpecifyRolesStep" runat="server" StepType="Step" 
                Title="Specify Roles" AllowReturn="False">
                <asp:RadioButtonList ID="RoleList" runat="server">
            <asp:WizardStep ID="SpecifyDetailsStep" runat="server" StepType="Step" 
                Title="User Details" AllowReturn="True">
                <h3>First Name:</h3>
                <asp:TextBox ID="firstnameTextBox" runat="server"></asp:TextBox>
                <h3>Last Name:</h3>
                <asp:TextBox ID="surnameTextBox" runat="server"></asp:TextBox>
                <h3>Company Name:</h3>
                <asp:TextBox ID="companyTextBox" runat="server"></asp:TextBox>
                <h3>Address 1</h3>
                <asp:TextBox ID="address1TextBox" runat="server"></asp:TextBox>
                <h3>Address 2</h3>
                <asp:TextBox ID="address2TextBox" runat="server"></asp:TextBox>
                <asp:TextBox ID="cityTextBox" runat="server"></asp:TextBox>
                <asp:TextBox ID="countryTextBox" runat="server"></asp:TextBox>
                <asp:TextBox ID="postcodeTextBox" runat="server"></asp:TextBox>
                <asp:TextBox ID="telephoneTextBox" runat="server"></asp:TextBox>
            <asp:WizardStep ID="VerifiedStep" runat="server" StepType="Step"
                Title="Verify User?" AllowReturn="true">
                <asp:CheckBox Checked="true" runat="server" ID="verifiedCheckBox" />
                <asp:Calendar SelectedDate="<%# DateTime.Now %>" ID="verifiedDate" runat="server" />
            <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">

Open in new window

now currently I am using the default wizard screen for adding the user (i am using the asp_net membership db).

At what point will the user be created by the wizard? Is it created once I move onto the next step or when the wizard finishes?

The reason I ask is that I in my FinishButtonClick I will add the roles, and userinformation to the db as well? Will I need to physically create the User if I utilise this method? (i.e. does it stop the insert?

    protected void RegisterUser_FinishButtonClick(object sender, WizardNavigationEventArgs e)
        //1st add the rolle to the user
        // Reference the SpecifyRolesStep WizardStep
        WizardStep SpecifyRolesStep = RegisterUser.FindControl("SpecifyRolesStep") as WizardStep;
        // Reference the RoleList CheckBoxList
        RadioButtonList RoleList = SpecifyRolesStep.FindControl("RoleList") as RadioButtonList;
        Roles.AddUserToRole(RegisterUser.UserName, RoleList.SelectedItem.Text);

        //verify user

        //insert table details


Open in new window

Who is Participating?
Carl TawnConnect With a Mentor Systems and Integration DeveloperCommented:
The wizard will attempt to create the user as soon as the "Create User" button is clicked on the first page of the wizard.

You can handle the CreatingUser[ and CreatedUser events if you need to customise the behaviour.
flynnyAuthor Commented:
Thats Great.

Ok if the user is created as soon as the create button is created. How do I get hold of the user object that has just been created?
Carl TawnSystems and Integration DeveloperCommented:
You can get the user using the Username property of the CreateUserWizard:
MembershipUser newUser = Membership.GetUser(YourCreateUserWizard.UserName);

Open in new window

flynnyAuthor Commented:
Sorry Carl,

Its been a long day, I shoudl have seen that.

Also, For some reason the OnFinishedButton click method is not firing? am I missing something out?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.