ProfileGroupBase Class

ProfileGroupBase Class


Provides untyped access to grouped ASP.NET profile property values.

Namespace:   System.Web.Profile
Assembly:  System.Web (in System.Web.dll)


public class ProfileGroupBase


Creates an instance of the ProfileGroupBase class.


Gets or sets a grouped profile property value indexed by the property name.


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)


Serves as the default hash function. (Inherited from Object.)


Gets the value of a grouped profile property.


Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodInit(ProfileBase, String)

Used by ASP.NET to initialize the grouped profile property values and information.


Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodSetPropertyValue(String, Object)

Sets the value of a grouped profile property.


Returns a string that represents the current object.(Inherited from Object.)

The ProfileGroupBase class is used by ASP.NET to create grouped properties in the Profile property for the current HttpContext. When properties are specified as a group of properties using the group Element for properties for profile (ASP.NET Settings Schema), ASP.NET creates a new class with strongly typed accessors for each property in the group. The new class inherits the ProfileGroupBase base class. The strongly typed accessors of the new class call the GetPropertyValue and SetPropertyValue methods of the ProfileGroupBase base class to retrieve and set profile property values, respectively.

The ProfileGroupBase passes calls to get and set property values to the class that inherits the ProfileBase class that is supplied to the Init method of the ProfileGroupBase class. See the ProfileBase class for more information on behaviors, exceptions, and so on.

This class is not intended to be created from your code.

The following Web.config file specifies a user profile that contains a group of properties with a group name of Address. The grouped properties generated for the Profile property of the current HttpContext will be preceded by the group name, for example, Profile.Address.Street. The second example shows an ASP.NET page that stores and retrieves the configured profile properties.

    <add name="SqlServices" connectionString=
      "Data Source=localhost;Integrated Security=SSPI;Initial Catalog=aspnetdb;" />

    <authentication mode="Forms" >
      <forms loginUrl="login.aspx"
        name=".ASPXFORMSAUTH" />

      <deny users="?" />

    <membership defaultProvider="SqlProvider" 
        <clear />
          applicationName="MyApplication" />

    <profile enabled="true" defaultProvider="SqlProvider">
          type="System.Web.Profile.SqlProfileProvider" />

        <add name="ZipCode" />
        <group name="Address">
          <add name="Street" />
          <add name="City" />
          <add name="State" />
          <add name="CountryOrRegion" />

The following code example shows an ASP.NET page that reads and sets the grouped properties specified for the user profile.

System_CAPS_security Security Note

This example contains a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview.

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<script runat="server">

public void Page_Load()
  if (!IsPostBack)
    StreetTextBox.Text          = Profile.Address.Street;
    CityTextBox.Text            = Profile.Address.City;
    StateTextBox.Text           = Profile.Address.State;
    CountryOrRegionTextBox.Text = Profile.Address.CountryOrRegion;
    ZipCodeTextBox.Text         = Profile.ZipCode;

public void UpdateButton_OnClick(object sender, EventArgs args)
  Profile.Address.Street          = StreetTextBox.Text;
  Profile.Address.City            = CityTextBox.Text;
  Profile.Address.State           = StateTextBox.Text;
  Profile.Address.CountryOrRegion = CountryOrRegionTextBox.Text;
  Profile.ZipCode                 = ZipCodeTextBox.Text;

<html xmlns="" >
<title>Home Page</title>
<h3>Address Information for <%=User.Identity.Name%></h3>
<form id="form1" runat="server">
  <table border="1" cellpadding="2" cellspacing="2">
      <td>Street Address</td>
      <td><asp:Textbox id="StreetTextBox" runat="server" columns="30" /></td>
      <td><asp:Textbox id="CityTextBox" runat="server" columns="20" /></td>
      <td><asp:Textbox id="StateTextBox" runat="server" columns="20" /></td>
      <td>Zip Code</td>
      <td><asp:Textbox id="ZipCodeTextBox" runat="server" columns="10" /></td>
      <td><asp:Textbox id="CountryOrRegionTextBox" runat="server" columns="20" /></td>
  <asp:Button id="UpdateButton" runat="server" OnClick="UpdateButton_OnClick" Text="Update Address" />


.NET Framework
Available since 2.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
© 2015 Microsoft