Wednesday, 20 July 2011

Using the CreateUserWizard Control With ASP.NET 4.0


In this tutorial we will explore ASP.NET's CreateUserWizard Control by demonstrating how we can use this to easily create accounts from our own website.

Creating a New Account With the ASP.NET Website Administration Tool
At this point in the tutorial I have created a new ASP.NET Empty Web Site in Microsoft Visual Web Developer and have added in a blank Web Form. What we are going to do now is go through the steps of creating a user with the ASP.NET Website Administration Tool. To do this:
  1. Click the ASP.NET Configuration icon in the Solution Explorer to open up the ASP.NET Website Administration Tool.
  2. In the ASP.NET Website Administration Tool click the Security tab.
  3. Under the Users header click the Select authentication type link.
  4. Select From the internet and click Done.
  5. Under the Users header click the Create Users link.
  6. Create a new user and click Done.
  7. Close the ASP.Net Website Administration Tool.
This method works for all of the accounts that you would need to create, but is simply not an option if we want our users to create their own accounts. In this case we would use the CreateUserWizard Control.

We migrated our web sites to Server Intellect over one weekend and the setup was so smooth that we were up and running right away. They assisted us with everything we needed to do for all of our applications. With Server Intellect's help, we were able to avoid any headaches!

Creating a New Account With the CreateUserWizard Control
What we want to do now is add a CreateUserWizard Control to our Web Form. To do this, open up your Web Form into design mode and:
  1. Expand the Login tab in your toolbox.
  2. Drag and drop the CreateUserWizard Control onto your Web Form.
It is important to note that the CreateUserWizard Control can be customized to accept custom data or even to have custom steps for account creation. For now, we are going to leave the Control as default and create a new account from our website. At this point we want to load up our website. You will see the CreateUserWizard Control, go ahead and fill out the information and click Create User. The CreateUserWizard Control will now change views to the Complete view, which simply displays a success message and a Continue Button that really doesn't do anything by default. (Note: If we wanted to make the Continue button link to a Login page, we could change the CreateUserWizard Control's ContinueDestinationPageUrl Property to that page.) At this point we just want to close our website down.

To check and make sure that our account was actually created, we can load up the ASP.NET Website Administration Tool again. To do this through the CreateUserWizard Control:
  1. Expand the CreateUserWizard Tasks menu.
  2. SS1.jpg
  3. Click Administer Website.
  4. In the ASP.NET Website Administration Tool click the Security tab.
  5. Under the Users header click the Manage Users link.
You will notice that this page contains a list of all Users for your website. You should have two, the one we created earlier with the ASP.NET Website Administration Tool and the one that we created from our own website.

We used over 10 web hosting companies before we found Server Intellect. Their dedicated servers and add-ons were setup swiftly, in less than 24 hours. We were able to confirm our order over the phone. They respond to our inquiries within an hour. Server Intellect's customer support and assistance are the best we've ever experienced.

The Web Form source looks like this:
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:CreateUserWizard ID="CreateUserWizard1" runat="server" 
            AutoGeneratePassword="True">
            <WizardSteps>
                <asp:CreateUserWizardStep runat="server" />
                <asp:CompleteWizardStep runat="server" />
            </WizardSteps>
        </asp:CreateUserWizard>
    
    </div>
    </form>
</body>

No comments:

Post a Comment