ProfileGroupBase.SetPropertyValue(String, Object) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
그룹화된 프로필 속성의 값을 설정합니다.
public:
void SetPropertyValue(System::String ^ propertyName, System::Object ^ propertyValue);
public void SetPropertyValue(string propertyName, object propertyValue);
member this.SetPropertyValue : string * obj -> unit
Public Sub SetPropertyValue (propertyName As String, propertyValue As Object)
매개 변수
- propertyName
- String
설정할 그룹화된 속성의 이름입니다.
- propertyValue
- Object
그룹화된 속성에 할당할 값입니다.
예제
다음 ASP.NET 페이지에서는 사용자 프로필에 지정된 그룹화된 속성을 읽고 설정합니다. 사용자 프로필의 그룹화된 속성을 지정하는 Web.config 파일의 예제는 클래스에 제공된 예제를 ProfileGroupBase 참조하세요.
중요합니다
이 예제에는 잠재적인 보안 위협인 사용자 입력을 허용하는 텍스트 상자가 포함되어 있습니다. 기본적으로 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>
설명
ASP.NET 클래스를 ProfileBase 사용하여 사용자 프로필에 사용되는 클래스를 만듭니다. 사용자 프로필을 사용하도록 설정된 애플리케이션이 시작되면 ASP.NET 클래스에서 상속되는 새 형식 ProfileCommon클래스를 ProfileBase 만듭니다. 강력한 형식의 접근자는 프로필 요소(ASP.NET 설정 스키마) 구성 섹션에 정의된 각 그룹 및 속성에 대한 클래스에 추가 ProfileCommon 됩니다. 클래스의 강력한 형식의 ProfileCommon 접근자가 메서드를 호출 SetPropertyValue 하여 그룹화된 속성 값을 ProfileProvider 데이터 원본에 저장할 값으로 전달합니다.
메서드를 SetPropertyValue 사용하여 이름으로 애플리케이션에 대한 사용자 프로필의 그룹화된 속성에 값을 할당할 수 있습니다. 값은 형식으로 object, 입력되고 형식 검사는 컴파일 시간이 아니라 런타임에 수행됩니다. 프로필 속성 값에 대한 강력한 형식의 액세스의 경우 이름별로 그룹화된 속성에 속성 그룹의 Profile 멤버로 액세스할 수 있습니다. 예를 들면 다음과 같습니다 Profile.Address.City.