Solved

Help with CreateUserWizard Control

Posted on 2014-04-14
4
562 Views
Last Modified: 2014-04-17
Hi all,

I have the following CreateUserWizard control

    <h2>Create a New User Account</h2>
    
    <asp:CreateUserWizard ID="RegisterUser" runat="server" 
        ContinueDestinationPageUrl="~/AdminOnly/Default.aspx" 
        onactivestepchanged="RegisterUser_ActiveStepChanged" 
        OnFinishButtonClick="RegisterUser_FinishButtonClick"
        LoginCreatedUser="False">
        <WizardSteps>
            <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
            </asp:CreateUserWizardStep>
            <asp:WizardStep ID="SpecifyRolesStep" runat="server" StepType="Step" 
                Title="Specify Roles" AllowReturn="False">
                <asp:RadioButtonList ID="RoleList" runat="server">
                </asp:RadioButtonList>
            </asp:WizardStep>
            <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>
                <h3>City</h3>
                <asp:TextBox ID="cityTextBox" runat="server"></asp:TextBox>
                <h3>Country</h3>
                <asp:TextBox ID="countryTextBox" runat="server"></asp:TextBox>
                <h3>PostCode</h3>
                <asp:TextBox ID="postcodeTextBox" runat="server"></asp:TextBox>
                <h3>Telephone</h3>
                <asp:TextBox ID="telephoneTextBox" runat="server"></asp:TextBox>
            </asp:WizardStep>    
            <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:WizardStep>
            <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
            </asp:CompleteWizardStep>
        </WizardSteps>
    </asp:CreateUserWizard>

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

0
Comment
Question by:flynny
  • 2
  • 2
4 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 39998902
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.
0
 

Author Comment

by:flynny
ID: 39999161
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?
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 39999186
You can get the user using the Username property of the CreateUserWizard:
MembershipUser newUser = Membership.GetUser(YourCreateUserWizard.UserName);

Open in new window

0
 

Author Comment

by:flynny
ID: 39999212
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?
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question