ProfileGroupBase.Item[String] Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene o imposta un valore della proprietà del profilo raggruppato indicizzato in base al nome della proprietà.
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
Parametri
- propertyName
- String
Nome della proprietà del profilo raggruppata.
Valore della proprietà
Valore della proprietà del profilo raggruppata specificata.
Esempio
Nell'esempio di codice seguente viene illustrata una pagina ASP.NET che legge e imposta le proprietà raggruppate specificate per il profilo utente. Per un esempio di file di Web.config che specifica un gruppo di proprietà nel profilo, vedere l'esempio fornito per la ProfileGroupBase classe .
Importante
Questo esempio contiene una casella di testo che accetta l'input dell'utente, che rappresenta una potenziale minaccia per la sicurezza. Per impostazione predefinita, ASP.NET pagine Web verificare che l'input dell'utente non includa elementi SCRIPT o HTML. Per altre informazioni, vedere Cenni preliminari sugli exploit di script.
<%@ 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>
Commenti
È possibile utilizzare questa proprietà per recuperare o impostare i valori delle proprietà raggruppate del profilo utente per l'applicazione. I valori restituiti vengono tipizzati come Object e devono essere cast come tipo di oggetto specifico quando vengono recuperati. Per l'accesso fortemente tipizzato ai valori delle proprietà del profilo, è possibile accedere alla proprietà in base al nome come membro di un gruppo della HttpContext.Profile proprietà, Profile.Address.Cityad esempio .