Wednesday, 20 July 2011

Using the ChangePassword Control With ASP.NET 4.0


In this tutorial we will explore the ChangePassword Control by demonstrating how to create a User Account with the ASP.NET Website Administration Tool and then change the password to that account from our own website.

Adding the ChangePassword Control
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 want to do now is create a new ChangePassword Control on this page. In order to do this:
  1. Expand the Login tab in your toolbox.
  2. Drag and drop a ChangePassword Control onto your Web Form.
  3. Under the ChangePassword Control's Properties menu, find the DisplayUserName property and set it to True.
SS1.gif

This will add an area for the Username at the top of the Control. I have enabled the DisplayUserName property here so that we can change our password even if we are not currently logged in. This will make it easier for us to test the control.

We chose Server Intellect for its dedicated servers, for our web hosting. They have managed to handle virtually everything for us, from start to finish. And their customer service is stellar.

Creating a New Account
Next we need to create a new user account, 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.

If you're looking for a really good web host, try Server Intellect - we found the setup procedure and control panel, very easy to adapt to and their IT team is awesome!

Testing
To test this out let's go ahead and load up the website. You should see the ChangePassword Control, if we fill out the information using the account that we created earlier, we will get to the Success Page of the ChangePassword Control indicating that our password has been changed. Load up the website again and change your password back to the original to ensure that the password was indeed changed.

Server Intellect assists companies of all sizes with their hosting needs by offering fully configured server solutions coupled with proactive server management services. Server Intellect specializes in providing complete internet-ready server solutions backed by their expert 24/365 proactive support team.

The Web Form source looks like this:
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ChangePassword ID="ChangePassword1" runat="server" DisplayUserName="True">
        </asp:ChangePassword>
    </div>
    </form>
</body>

No comments:

Post a Comment