ProfileBase.GetProfileGroup メソッド
アセンブリ: System.Web (system.web.dll 内)

Dim instance As ProfileBase Dim groupName As String Dim returnValue As ProfileGroupBase returnValue = instance.GetProfileGroup(groupName)
戻り値
指定されたグループ名を使用して構成されたプロパティ グループに対する ProfileGroupBase オブジェクト。

例外の種類 | 条件 |
---|---|
System.Configuration.Provider.ProviderException | properties 構成セクションに、指定されたプロファイル プロパティ グループ名が見つかりませんでした。 |

プロファイル プロパティは、編成しやすいように複数のグループに分けることができます。GetProfileGroup プロパティは、プロパティのグループをグループ名で取得するために使用できます。また、各ページごとに使用できる Profile プロパティのメンバとしてグループ名を指定することで、グループ内のプロファイル プロパティにアクセスすることもできます。たとえば、Address プロファイル グループのメンバである ZipCode プロファイル プロパティには、Profile.Address.ZipCode を使用してアクセスできます。

Address というグループ名を持つプロパティ グループを含んだユーザー プロファイルを指定する Web.config ファイルの例を次に示します。現在の HttpContext の Profile プロパティに対してグループ化済みプロパティを生成すると、プロパティの前にグループ名が付きます。たとえば、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>
次の ASP.NET ページでは、ユーザー プロファイルに対して指定された、グループ化されたプロパティを読み込んだり、設定したりします。
<%@ Page Language="VB" %> <script runat="server"> Public Sub Page_Load() If Not IsPostBack Then StreetTextBox.Text = Profile.Address.Street CityTextBox.Text = Profile.Address.City StateTextBox.Text = Profile.Address.State CountryOrRegionTextBox.Text = Profile.Address.CountryOrRegion ZipCodeTextBox.Text = Profile.ZipCode End If End Sub Public Sub UpdateButton_OnClick(sender As Object, args As EventArgs) Profile.Address.Street = StreetTextBox.Text Profile.Address.City = CityTextBox.Text Profile.Address.State = StateTextBox.Text Profile.Address.CountryOrRegion = CountryOrRegionTextBox.Text Profile.ZipCode = ZipCodeTextBox.Text End Sub </script> <html> <head> <title>Home Page</title> </head> <body> <h3>Address Information for <%=User.Identity.Name%></h3> <form runat="server"> <table border=1 cellpadding=2 cellspacing=2> <tr> <td>Street Address</td> <td><asp:Textbox id="StreetTextBox" runat="server" columns="30" /></td> </tr> <tr> <td>City</td> <td><asp:Textbox id="CityTextBox" runat="server" columns="20" /></td> </tr> <tr> <td>State</td> <td><asp:Textbox id="StateTextBox" runat="server" columns="20" /></td> </tr> <tr> <td>Zip Code</td> <td><asp:Textbox id="ZipCodeTextBox" runat="server" columns="10" /></td> </tr> <tr> <td>Country</td> <td><asp:Textbox id="CountryOrRegionTextBox" runat="server" columns="20" /></td> </tr> </table> <asp:Button id="UpdateButton" runat="server" OnClick="UpdateButton_OnClick" Text="Update Address" /> </form> </body> </html>
<%@ Page Language="C#" %> <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; } </script> <html> <head> <title>Home Page</title> </head> <body> <h3>Address Information for <%=User.Identity.Name%></h3> <form runat="server"> <table border=1 cellpadding=2 cellspacing=2> <tr> <td>Street Address</td> <td><asp:Textbox id="StreetTextBox" runat="server" columns="30" /></td> </tr> <tr> <td>City</td> <td><asp:Textbox id="CityTextBox" runat="server" columns="20" /></td> </tr> <tr> <td>State</td> <td><asp:Textbox id="StateTextBox" runat="server" columns="20" /></td> </tr> <tr> <td>Zip Code</td> <td><asp:Textbox id="ZipCodeTextBox" runat="server" columns="10" /></td> </tr> <tr> <td>Country</td> <td><asp:Textbox id="CountryOrRegionTextBox" runat="server" columns="20" /></td> </tr> </table> <asp:Button id="UpdateButton" runat="server" OnClick="UpdateButton_OnClick" Text="Update Address" /> </form> </body> </html>

Windows 98, Windows 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
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からProfileBase.GetProfileGroup メソッドを検索する場合は、下記のリンクをクリックしてください。

- ProfileBase.GetProfileGroup メソッドのページへのリンク