ProfileBase.GetProfileGroup Method
Assembly: System.Web (in system.web.dll)
public ProfileGroupBase GetProfileGroup ( String groupName )
public function GetProfileGroup ( groupName : String ) : ProfileGroupBase
Not applicable.
Parameters
- groupName
The name of the group of properties.
Return Value
A ProfileGroupBase object for a group of properties configured with the specified group name.| Exception type | Condition |
|---|---|
| The specified profile property group name was not found in the properties configuration section. |
Profile properties can be separated into groups for better organization. The GetProfileGroup property can be used to retrieve a group of properties by the group name. You can also access a profile property in a group by specifying the group name as a member of the Profile property available on each page. For example, the ZipCode profile property that is a member of the Address profile group could be accessed using Profile.Address.ZipCode.
The following Web.config file specifies a user profile that contains 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.
<configuration>
<connectionStrings>
<add name="SqlServices" connectionString=
"Data Source=localhost;Integrated Security=SSPI;Initial Catalog=aspnetdb;" />
</connectionStrings>
<system.web>
<authentication mode="Forms" >
<forms loginUrl="login.aspx"
name=".ASPXFORMSAUTH" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
<membership defaultProvider="SqlProvider"
userIsOnlineTimeWindow="15">
<providers>
<clear />
<add
name="SqlProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="SqlServices"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="true"
requiresUniqueEmail="false"
passwordFormat="Hashed"
applicationName="MyApplication" />
</providers>
</membership>
<profile defaultProvider="SqlProvider">
<providers>
<add
name="SqlProvider"
connectionStringName="SqlServices"
applicationName="MyApplication"
type="System.Web.Profile.SqlProfileProvider" />
</providers>
<properties>
<add name="ZipCode" />
<group name="Address">
<add name="Street" />
<add name="City" />
<add name="State" />
<add name="CountryOrRegion" />
</group>
</properties>
</profile>
</system.web>
</configuration>
The following ASP.NET page reads and sets the grouped properties specified for the user profile.
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 (Visual Studio). |
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.
Security Note: