IWebPart.TitleUrl 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 URL per informazioni supplementari su un WebPart controllo .
public:
property System::String ^ TitleUrl { System::String ^ get(); void set(System::String ^ value); };
public string TitleUrl { get; set; }
member this.TitleUrl : string with get, set
Public Property TitleUrl As String
Valore della proprietà
Stringa che rappresenta un URL per ulteriori informazioni su un WebPart controllo. Il valore predefinito è una stringa vuota ("").
Esempio
Nell'esempio di codice seguente viene illustrato l'uso dichiarativo e programmatico della TitleUrl proprietà . Il codice sorgente completo per l'esempio è disponibile nella sezione Esempio della panoramica della IWebPart classe.
La prima parte dell'esempio di codice mostra come il controllo utente implementa la TitleUrl proprietà .
public string TitleUrl
{
get
{
object objTitle = ViewState["TitleUrl"];
if (objTitle == null)
return String.Empty;
return (string)objTitle;
}
set
{
ViewState["TitleUrl"] = value;
}
}
Public Property TitleUrl() As String _
Implements IWebPart.TitleUrl
Get
Dim objTitle As Object = ViewState("TitleUrl")
If objTitle Is Nothing Then
Return String.Empty
End If
Return CStr(objTitle)
End Get
Set(ByVal value As String)
ViewState("TitleUrl") = value
End Set
End Property
La seconda parte dell'esempio di codice illustra il metodo nel controllo utente che imposta a livello di codice il valore della TitleUrl proprietà quando un utente seleziona il nome di proprietà appropriato dai pulsanti di opzione nella pagina, imposta un nuovo valore nella casella di testo e quindi fa clic sul pulsante Aggiorna .
Importante
In questo esempio è presente 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.
// Update the selected IWebPart property value.
void Button1_Click(object sender, EventArgs e)
{
String propertyValue = Server.HtmlEncode(TextBox3.Text);
TextBox3.Text = String.Empty;
switch (RadioButtonList1.SelectedValue)
{
case "title":
this.Title = propertyValue;
break;
case "description":
this.Description = propertyValue;
break;
case "catalogiconimageurl":
this.CatalogIconImageUrl = propertyValue;
break;
case "titleiconimageurl":
this.TitleIconImageUrl = propertyValue;
break;
case "titleurl":
this.TitleUrl = propertyValue;
break;
default:
break;
}
}
' Update the selected IWebPart property value.
Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim propertyValue As String = Server.HtmlEncode(TextBox3.Text)
TextBox3.Text = String.Empty
Select Case RadioButtonList1.SelectedValue
Case "title"
Me.Title = propertyValue
Case "description"
Me.Description = propertyValue
Case "catalogiconimageurl"
Me.CatalogIconImageUrl = propertyValue
Case "titleiconimageurl"
Me.TitleIconImageUrl = propertyValue
Case "titleurl"
Me.TitleUrl = propertyValue
Case Else
End Select
End Sub 'Button1_Click
La terza parte dell'esempio di codice mostra come viene fatto riferimento al controllo utente che implementa l'interfaccia IWebPart in un WebPartZone controllo e come la TitleUrl proprietà viene impostata in modo dichiarativo sul controllo. Si noti che se non si fornisce un URL a una pagina reale e quindi un utente fa clic sul collegamento nella barra del titolo, viene visualizzato un messaggio di errore.
<%@ page language="c#" %>
<%@ register tagprefix="uc1"
tagname="AccountUserControlCS"
src="AccountUserControlcs.ascx"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>
Personalizable User Control with IWebPart Properties
</title>
</head>
<body>
<form id="form1" runat="server">
<asp:webpartmanager id="WebPartManager1" runat="server" />
<asp:webpartzone
id="zone1"
runat="server"
headertext="Main"
CloseVerb-Enabled="false">
<zonetemplate>
<uc1:AccountUserControlCS
runat="server"
id="accountwebpart"
title="Account Form"
Description="Account Form with default values."
CatalogIconImageUrl="MyCatalogIcon.gif"
TitleIconImageUrl="MyTitleIcon.gif"
TitleUrl="MyUrl.html"/>
</zonetemplate>
</asp:webpartzone>
</form>
</body>
</html>
<%@ page language="VB" %>
<%@ register tagprefix="uc1"
tagname="AccountUserControlVB"
src="AccountUserControlvb.ascx"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>
Personalizable User Control with IWebPart Properties
</title>
</head>
<body>
<form id="form1" runat="server">
<asp:webpartmanager id="WebPartManager1" runat="server" />
<asp:webpartzone
id="zone1"
runat="server"
headertext="Main"
CloseVerb-Enabled="false">
<zonetemplate>
<uc1:AccountUserControlVB
runat="server"
id="accountwebpart"
title="Account Form"
Description="Account Form with default values."
CatalogIconImageUrl="MyCatalogIcon.gif"
TitleIconImageUrl="MyTitleIcon.gif"
TitleUrl="MyUrl.html"/>
</zonetemplate>
</asp:webpartzone>
</form>
</body>
</html>
Commenti
Quando si assegna un URL alla TitleUrl proprietà , il titolo del controllo diventa un collegamento. Lo scopo di questa proprietà è fornire agli utenti finali un modo pratico per accedere a informazioni aggiuntive su un controllo. Le informazioni aggiuntive potrebbero fornire dati sul copyright, dati di contatto, dettagli sull'autore del controllo o un riepilogo dello scopo del controllo.
Annotazioni
In genere, non si usa la TitleUrl proprietà per collegarsi al contenuto della Guida. Il modo migliore per fornire un collegamento alla Guida per un controllo consiste nell'usare la HelpUrl proprietà .