HtmlLink Constructor
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the HtmlLink class.
public:
HtmlLink();
public HtmlLink ();
Public Sub New ()
Examples
The following code example demonstrates how to programmatically declare an HtmlLink control and define its properties. For a complete, working code example, see the HtmlLink class overview topic.
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
Remarks
Use this constructor to create and initialize a new instance of the HtmlLink control.
Applies to
Collaborer avec nous sur GitHub
La source de ce contenu se trouve sur GitHub, où vous pouvez également créer et examiner les problèmes et les demandes de tirage. Pour plus d’informations, consultez notre guide du contributeur.