Page.Header Property
.NET Framework 2.0
Gets the document header for the page if the head element is defined with a runat=server in the page declaration.
Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)
Assembly: System.Web (in system.web.dll)
'Declaration Public ReadOnly Property Header As HtmlHead 'Usage Dim instance As Page Dim value As HtmlHead value = instance.Header
/** @property */ public HtmlHead get_Header ()
public function get Header () : HtmlHead
Not applicable.
Property Value
An HtmlHead containing the page header.The following code example demonstrates how to access the HtmlHead control programmatically using the Header property. A title element and style element are added to the head element of the page.
<%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) ' Create a Style object for the body of the page. Dim bodyStyle As New Style() bodyStyle.ForeColor = System.Drawing.Color.Blue bodyStyle.BackColor = System.Drawing.Color.LightGray ' Add the style rule named bodyStyle to the header ' of the current page. The rule is for the body HTML element. Page.Header.StyleSheet.CreateStyleRule(bodyStyle, Nothing, "body") ' Add the page title to the header element. Page.Header.Title = "HtmlHead Example" End Sub </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="head1" runat="server"> <title>To be replaced.</title> </head> <body> <form id="Form1" runat="server"> <h3>HtmlHead Class Example </h3> <asp:label id="Label1" text = "View the HTML source code of this page to see the title and body style added to the header element." runat="server"> </asp:label> </form> </body> </html>
Community Additions
ADD
Show: