Condividi tramite


HtmlLink.Href Proprietà

Definizione

Ottiene o imposta la destinazione dell'URL del collegamento specificato nel controllo HtmlLink.

public:
 virtual property System::String ^ Href { System::String ^ get(); void set(System::String ^ value); };
public virtual string Href { get; set; }
member this.Href : string with get, set
Public Overridable Property Href As String

Valore della proprietà

Destinazione dell'URL del collegamento.

Esempio

Nell'esempio di codice seguente viene illustrata l'impostazione della Href proprietà su un foglio di stile CSS (Cascading) salvato nella stessa directory della pagina Web. Per un esempio completo di codice funzionante, vedere l'argomento panoramica della HtmlLink classe.

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class HtmlLinkcs_aspx
{
    void Page_Init(object sender, EventArgs e)
    {
        // Create an instance of HtmlLink.
        HtmlLink myHtmlLink = new HtmlLink();
        myHtmlLink.Href = "StyleSheet.css";     
        myHtmlLink.Attributes.Add("rel", "stylesheet");
        myHtmlLink.Attributes.Add("type", "text/css");   

        // Add the instance of HtmlLink to the <HEAD> section of the page.
        head1.Controls.Add(myHtmlLink);
    }
}
// Define an HtmlLink control.
HtmlLink myHtmlLink = new HtmlLink();
myHtmlLink.Href = "~/StyleSheet.css";
myHtmlLink.Attributes.Add("rel", "stylesheet");
myHtmlLink.Attributes.Add("type", "text/css");
' Define an HtmlLink control.
Dim myHtmlLink As New HtmlLink()
myHtmlLink.Href = "~/StyleSheet.css"
myHtmlLink.Attributes.Add("rel", "stylesheet")
myHtmlLink.Attributes.Add("type", "text/css")
Partial Class HtmlLinkvb_aspx

    Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)

        ' Create an instance of HtmlLink.
        Dim myHtmlLink As HtmlLink = New HtmlLink()
        myHtmlLink.Href = "StyleSheet.css"
        myHtmlLink.Attributes.Add("rel", "stylesheet")
        myHtmlLink.Attributes.Add("type", "text/css")

        ' Add the instance of HtmlLink to the <HEAD> section of the page.
        head1.Controls.Add(myHtmlLink)

    End Sub

End Class

Commenti

La Href proprietà specifica la destinazione URL del collegamento specificato nel HtmlLink controllo . È possibile utilizzare questa proprietà per specificare la posizione di un foglio di stile CSS esterno.

Si applica a