Skip Navigation LinksHome : CBC Classes : ASP.Net : Profile Information (Extending Membership Data)

CS218 ASP.Net - Profile Information

Hopefully you realize how helpful and powerful the ASP.Net Membership controls are. They can really save you a lot of time and effort when it comes to adding members and security to your web site.

But another cool thing about Membership is that it can be extended to track other pieces of user data. That is, out of the box it will track usernames, passwords, email addresses and security questions and answers. But it can also track any other piece of user data that you desire. For example, cell phone number, home address etc. And even better, rather than forcing you, the web site administrator to manage this data, it's built to allow each user to edit and manage their own data.

  1. What is profile data (video)
  2. Adding profile information to the database via web.config (video, notes)
  3. Displaying a user's profile data (video, notes)
  4. Allowing a user to change their profile data (video)
  5. Displaying profile data for all users (video)
  6. Changing the profile data for a different user. Note, this is typically an admin function (video)
Adding Profile data to web.config

Adding profile data requires editing the main web.config file for the website. The <profile> section must go inside the <system.web> section. You can have as many <add> sections as you want. Use one for each piece of data that you want to track. Just make sure that you only use alphanumeric characters!

      <add name="cellPhone" />
      <add name="homePhone" />
      <add name="address" />
      <add name="state" />
      <add name="zip" />
Displaying a users profile information

    Protected void Page_Load(object sender, EventArgs e)
        if ( IsPostBack != true) {
            lblCellPhone.text = Profile.cellPhone
            lblHomePhone.text = Profile.homePhone
            lblAddress.text = Profile.address
            lblState.text = Profile.state
            lblZip.text =
Changing a users profile information

Read data the same way, but put in textboxes instead of labels.

    Protected void Page_Load(object sender, EventArgs e)
        if ( !IsPostBack ) {
            txtCellPhone.text = Profile.cellPhone
            txtHomePhone.text = Profile.homePhone
            txtAddress.text = Profile.address
            txtState.text = Profile.state
            txtZip.text =
        End If
    End Sub
    Protected Sub cmdUpdateProfile_Click(sender As Object, e As System.EventArgs) Handles cmdUpdateProfile.Click
            Profile.cellPhone = txtCellPhone.text
            Profile.homePhone = txtHomePhone.text  
            Profile.address = txtAddress.text 
            Profile.state = txtState.text  
   = txtZip.text  
    End Sub