ProfileBase.Properties 속성

정의

프로필의 각 속성에 대한 SettingsProperty 개체의 컬렉션을 가져옵니다.

public:
 static property System::Configuration::SettingsPropertyCollection ^ Properties { System::Configuration::SettingsPropertyCollection ^ get(); };
public static System.Configuration.SettingsPropertyCollection Properties { get; }
member this.Properties : System.Configuration.SettingsPropertyCollection
Public Shared ReadOnly Property Properties As SettingsPropertyCollection

속성 값

SettingsPropertyCollection

애플리케이션에 대한 프로필의 각 속성에 대한 SettingsPropertyCollection 개체의 SettingsProperty입니다.

예외

Web.config 파일의 profile 섹션에 지정된 속성 형식을 만들 수 없는 경우

또는

Web.config 파일의 profile 섹션에서 속성의 allowAnonymous 특성이 true로 설정되어 있고 <anonymousIdentification> 요소의 enabled 특성이 false로 설정되어 있는 경우

또는

Web.config 파일의 profile 섹션에서 속성의 serializeAs 특성이 Binary로 설정되어 있고 지정된 typeIsSerializable 속성이 false를 반환하는 경우

또는

프로필 속성의 provider 특성을 사용하여 지정한 공급자 이름을 Providers 컬렉션에서 찾을 수 없는 경우

또는

프로필 속성에 지정된 type을 찾을 수 없는 경우

또는

프로필 속성이 profile 섹션의 inherits 특성에 지정된 기본 클래스에 대한 속성 이름과 일치하는 이름으로 지정된 경우

예제

다음 코드 예제에서는 개체의 정적 Properties 컬렉션에서 컨트롤에 속성을 바인딩 Name 하여 사용자 프로필의 SettingsProperty 속성 이름을 나열합니다GridView. 선택한 속성 값은 컬렉션을 사용하여 이름으로 검색됩니다 Item[] . 사용자 프로필의 속성을 지정하는 Web.config 파일의 예제는 클래스에 제공된 예제를 ProfileBase 참조하세요.

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Profile" %>

<!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)
  {
    PropertiesListBox.DataSource = ProfileBase.Properties;
    PropertiesListBox.DataBind();
  }

  if (PropertiesListBox.SelectedItem != null)
  {
    object propValue = Profile[PropertiesListBox.SelectedItem.Text];

    Type propType = propValue.GetType();

    // If the property is a value type, return ToString().

    if (propType == typeof(string) || propType.IsValueType)
    {
      ValueLabel.Visible = true;
      ValueGridView.Visible = false;
      ValueLabel.Text = propValue.ToString();
      return;
    }


    // Bind the property to a GridView.

    try
    {
      ValueGridView.DataSource = propValue;
      ValueGridView.DataBind();
      ValueGridView.Visible = true;
      ValueLabel.Visible = false; 
    }
    catch
    {
      // If the property is not bindable, return ToString().

      ValueLabel.Visible = true;
      ValueGridView.Visible = false;
      ValueLabel.Text = propValue.ToString();
    }
  }
}

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Home Page</title>
</head>
<body>

<h3>View Profile properties:</h3>

<form id="form1" runat="server">
  <table border="0" cellpadding="2" cellspacing="2">
    <tr>
      <td>Property</td>
      <td>Value</td>
    </tr>
    <tr>
      <td valign="top">
        <asp:ListBox runat="server" id="PropertiesListBox" Rows="10" AutoPostBack="True" DataTextField="Name" />
      </td>
      <td valign="top">
        <asp:GridView runat="Server" id="ValueGridView" Visible="False" />
        <asp:Label runat="Server" id="ValueLabel" Visible="False" />
      </td>
    </tr>
  </table>
</form>

</body>
</html>
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Web.Profile" %>

<!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
    PropertiesListBox.DataSource = ProfileBase.Properties
    PropertiesListBox.DataBind()
  End If

  If Not PropertiesListBox.SelectedItem Is Nothing Then
    Dim propValue As Object = Profile(PropertiesListBox.SelectedItem.Text)

    Dim propType As Type = propValue.GetType()

    ' If the property is a value type, return ToString().

    If propType Is GetType(String) Or propType.IsValueType Then
      ValueLabel.Visible = True
      ValueGridView.Visible = False
      ValueLabel.Text = propValue.ToString()
      Return
    End If


    ' Bind the property to a GridView.

    Try
      ValueGridView.DataSource = propValue
      ValueGridView.DataBind()
      ValueGridView.Visible = True
      ValueLabel.Visible = False 
    Catch
      ' If the property is not bindable, return ToString().

      ValueLabel.Visible = True
      ValueGridView.Visible = False
      ValueLabel.Text = propValue.ToString()
    End Try
  End If
End Sub

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Home Page</title>
</head>
<body>

<h3>View Profile properties:</h3>

<form id="form1" runat="server">
  <table border="0" cellpadding="2" cellspacing="2">
    <tr>
      <td>Property</td>
      <td>Value</td>
    </tr>
    <tr>
      <td valign="top">
        <asp:ListBox runat="server" id="PropertiesListBox" Rows="10" AutoPostBack="True" DataTextField="Name" />
      </td>
      <td valign="top">
        <asp:GridView runat="Server" id="ValueGridView" Visible="False" />
        <asp:Label runat="Server" id="ValueLabel" Visible="False" />
      </td>
    </tr>
  </table>
</form>

</body>
</html>

설명

이 속성은 속성 이름 및 형식을 포함 하는 애플리케이션에 대해 구성 된 프로필 속성에 대 한 정보를 사용할 수 있습니다. 각 속성의 참조할 ProfileProvider 수도 있습니다. ProfileProvider은 데이터 원본 간의 속성 값의 스토리지 및 검색을 관리합니다.

적용 대상

추가 정보