Share via


HtmlLink.Href Propiedad

Definición

Obtiene o establece la dirección URL de destino del vínculo especificado en el control 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

Valor de propiedad

String

La dirección URL de destino del vínculo.

Ejemplos

En el ejemplo de código siguiente se muestra cómo establecer la Href propiedad en una hoja de estilos en cascada (CSS) que se guarda en el mismo directorio que la página web. Para obtener un ejemplo completo de código de trabajo, consulte el tema de información general de la HtmlLink clase.

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

Comentarios

La Href propiedad especifica el destino de dirección URL del vínculo especificado en el HtmlLink control . Puede usar esta propiedad para especificar la ubicación de una hoja de estilos en cascada externa (CSS).

Se aplica a