다음을 통해 공유


ProfileGroupBase 클래스

정의

그룹화된 ASP.NET 프로필 속성 값에 대한 형식화되지 않은 액세스를 제공합니다.

public ref class ProfileGroupBase
public class ProfileGroupBase
type ProfileGroupBase = class
Public Class ProfileGroupBase
상속
ProfileGroupBase

예제

다음 Web.config 파일은 그룹 이름을 Address가진 속성 그룹을 포함하는 사용자 프로필을 지정합니다. 현재 HttpContext 속성에 Profile 대해 생성된 그룹화된 속성 앞에는 그룹 이름(예: )Profile.Address.Street이 있습니다. 두 번째 예제에서는 구성된 프로필 속성을 저장하고 검색하는 ASP.NET 페이지를 보여 줍니다.

<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 enabled="true" 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 페이지를 보여줍니다.

중요합니다

이 예제에는 잠재적인 보안 위협인 사용자 입력을 허용하는 텍스트 상자가 포함되어 있습니다. 기본적으로 ASP.NET 웹 페이지는 사용자 입력에 스크립트 또는 HTML 요소가 포함되지 않는지 확인합니다. 자세한 내용은 스크립트 악용 개요를 참조하세요.

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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 xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Home Page</title>
</head>
<body>
<h3>Address Information for <%=User.Identity.Name%></h3>
<form id="form1" 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="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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 xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Home Page</title>
</head>
<body>
<h3>Address Information for <%=User.Identity.Name%></h3>
<form id="form1" 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>

설명

클래스는 ProfileGroupBase ASP.NET 현재 HttpContext속성에 Profile 그룹화된 속성을 만드는 데 사용됩니다. 속성이 프로필 속성에 대해 group Element를 사용하여 속성 그룹으로 지정되는 경우 (ASP.NET 설정 스키마) ASP.NET 그룹의 각 속성에 대해 강력한 형식의 접근자를 사용하여 새 클래스를 만듭니다. 새 클래스는 기본 클래스를 ProfileGroupBase 상속합니다. 새 클래스의 강력한 형식의 접근자가 각각 기본 클래스의 ProfileGroupBase 메서드 및 SetPropertyValue 메서드를 호출 GetPropertyValue 하여 프로필 속성 값을 검색하고 설정합니다.

ProfileGroupBase 호출을 전달하여 클래스의 ProfileGroupBase 메서드에 제공된 클래스를 ProfileBase 상속하는 클래스에 Init 속성 값을 가져오고 설정합니다. ProfileBase 동작, 예외 등에 대한 자세한 내용은 클래스를 참조하세요.

이 클래스는 코드에서 만들 수 없습니다.

생성자

Name Description
ProfileGroupBase()

ProfileGroupBase 클래스의 인스턴스를 만듭니다.

속성

Name Description
Item[String]

속성 이름으로 인덱싱된 그룹화된 프로필 속성 값을 가져오거나 설정합니다.

메서드

Name Description
Equals(Object)

지정된 개체가 현재 개체와 같은지 여부를 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 사용됩니다.

(다음에서 상속됨 Object)
GetPropertyValue(String)

그룹화된 프로필 속성의 값을 가져옵니다.

GetType()

현재 인스턴스의 Type 가져옵니다.

(다음에서 상속됨 Object)
Init(ProfileBase, String)

ASP.NET 그룹화된 프로필 속성 값 및 정보를 초기화하는 데 사용됩니다.

MemberwiseClone()

현재 Object단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
SetPropertyValue(String, Object)

그룹화된 프로필 속성의 값을 설정합니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보