ProfileGroupBase.Item[String] Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Özellik adına göre dizine alınan gruplandırılmış profil özellik değerini alır veya ayarlar.
public:
property System::Object ^ default[System::String ^] { System::Object ^ get(System::String ^ propertyName); void set(System::String ^ propertyName, System::Object ^ value); };
public object this[string propertyName] { get; set; }
member this.Item(string) : obj with get, set
Default Public Property Item(propertyName As String) As Object
Parametreler
- propertyName
- String
Gruplandırılmış profil özelliğinin adı.
Özellik Değeri
Belirtilen gruplandırılmış profil özelliğinin değeri.
Örnekler
Aşağıdaki kod örneği, kullanıcı profili için belirtilen gruplandırılmış özellikleri okuyan ve ayarlayan bir ASP.NET sayfasını gösterir. Profildeki bir özellik grubunu belirten bir Web.config dosyası örneği için sınıf için ProfileGroupBase sağlanan örne bakın.
Önemli
Bu örnek, olası bir güvenlik tehdidi olan kullanıcı girişini kabul eden bir metin kutusu içerir. Varsayılan olarak, ASP.NET Web sayfaları kullanıcı girişinin betik veya HTML öğeleri içermediğini doğrular. Daha fazla bilgi için bkz. Betik Açıklarına Genel Bakış.
<%@ 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>
Açıklamalar
Uygulamanız için kullanıcı profilinin gruplandırılmış özellik değerlerini almak veya ayarlamak için bu özelliği kullanabilirsiniz. Döndürülen değerler olarak Object yazılır ve alındığında belirli nesne türü olarak yayınlanmalıdır. Profil özelliği değerlerine kesin olarak yazılan erişim için özelliğine, örneğinProfile.Address.City
, bir özellik grubunun HttpContext.Profile üyesi olarak ada göre erişebilirsiniz.