ProfileGroupBase 클래스

정의

그룹화된 ASP.NET 프로필 속성 값에 형식화되지 않은 액세스를 할 수 있도록 합니다.

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

예제

다음 Web.config 파일의 그룹 이름의 그룹 속성을 포함 하는 사용자 프로필을 지정 Address합니다. 에 대해 생성 된 그룹화 된 속성을 Profile 속성이 현재 HttpContext 붙습니다 그룹 이름, 예를 들어 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 요소가 포함되어 있지 않은지 확인합니다. 자세한 내용은 Script Exploits Overview를 참조하세요.

<%@ 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에서 만드는 데 그룹화 된 속성에는 Profile 현재 속성 HttpContext합니다. 속성은 사용 하 여 속성의 그룹으로 지정 하는 경우는 group 요소 (ASP.NET 설정 스키마) 프로필에 대 한 속성에 대 한, ASP.NET 그룹의 각 속성에 대 한 강력한 형식의 접근자를 사용 하 여 새 클래스를 만듭니다. 새 클래스 상속을 ProfileGroupBase 기본 클래스입니다. 새 클래스 호출의 강력한 형식의 접근자를 GetPropertyValue 하 고 SetPropertyValue 의 메서드는 ProfileGroupBase 기본 클래스를 검색 하 고 각각 프로필 속성 값을 설정 합니다.

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

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

생성자

ProfileGroupBase()

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

속성

Item[String]

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

메서드

Equals(Object)

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

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

기본 해시 함수로 작동합니다.

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

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

GetType()

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

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

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

MemberwiseClone()

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

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

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

ToString()

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

(다음에서 상속됨 Object)

적용 대상

추가 정보