HtmlHead クラス
アセンブリ: System.Web (system.web.dll 内)


HtmlHead コントロールは、サーバー上の HTML <head> 要素にプログラムでアクセスできます。HTML <head> 要素は、ページに関する追加情報のコンテナです。HTML サーバー コントロールの詳細については、「HTML サーバー コントロール」を参照してください。
HtmlHead コントロールは、実行時にアクセスできるページの書式情報を指定する場合に役立ちます。

プログラムで HtmlHead コントロールにアクセスして、ページの <head> 要素に <title> 要素および <style> 要素を動的に追加する方法を次のコード例に示します。
<%@ 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 to the header of the current page. Page.Header.StyleSheet.CreateStyleRule(bodyStyle, Nothing, "BODY") ' Add the page title to the header element. Page.Header.Title = "HtmlHead Example" End Sub </script> <html > <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>
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { // Create a Style object for the body of the page. Style bodyStyle = new Style(); bodyStyle.ForeColor = System.Drawing.Color.Blue; bodyStyle.BackColor = System.Drawing.Color.LightGray; // Add the style to the header of the current page. Page.Header.StyleSheet.CreateStyleRule(bodyStyle, null, "BODY"); // Add the page title to the header element. Page.Header.Title = "HtmlHead Example"; } </script> <html > <head id="head1" runat="server"> <title>To be replaced.</title> </head> <body> <form 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>


System.Web.UI.Control
System.Web.UI.HtmlControls.HtmlControl
System.Web.UI.HtmlControls.HtmlContainerControl
System.Web.UI.HtmlControls.HtmlGenericControl
System.Web.UI.HtmlControls.HtmlHead


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- HtmlHead クラスのページへのリンク