O'Reilly logo

ASP.NET 2.0: A Developer's Notebook by Wei-Meng Lee

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Manage User Settings

Note

Learn how to programmatically modify user's account information using the Membership class.

So far, you have seen how to modify users' information using the built-in controls that ship with ASP.NET 2.0. A much more versatile approach would be to modify user data programmatically. The Membership class makes this possible and is, in fact, the source of many of the APIs driving all the new Login controls in ASP.NET 2.0.

How do I do that?

In this lab, you will learn how to programmatically modify and access a user's settings. You will create a Web Form and populate it with text boxes and Button controls to let users perform tasks such as changing their passwords and identity validation questions, as well as updating their email addresses. All these tasks will be performed using the Membership and MembershipUser classes.

  1. Using the same project created in the last lab (C:\ASPNET20\chap-5-SecurityControls), add a new Web Form to the project (right-click the Members folder in Solution Explorer and then select Add New Item...; select Web Form). Name the Web Form UserInfo.aspx.

  2. Add a 3 6 table to the Web Form (Layout Insert Table) and populate it with the controls shown in Figure 5-36.

    The various controls on the UserInfo.aspx page

    Figure 5-36. The various controls on the UserInfo.aspx page

  3. When the form is first loaded, retrieve the user's information using the GetUser( ) method from the Membership class. It returns ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required