Accessing the Html Header in ASP.NET 2.0

Development

Posting this for future reference:

Dim header As Web.UI.HtmlControls.HtmlHead
header = TryCast(Me.Page.Header, Web.UI.HtmlControls.HtmlHead)
If (header IsNot Nothing) Then
Dim link As New HtmlLink
link.Attributes.Add("type", "text/css")
link.Attributes.Add("rel", "stylesheet")
link.Attributes.Add("media", "screen")
link.Attributes.Add("href", "~/style.css")
header.Controls.Add(link)
End If

Leave a Reply

Your e-mail address will not be published. Required fields are marked *