Share via


Page.Header 속성

정의

head 요소가 페이지 선언에서 runat=server로 정의된 경우 페이지의 문서 헤더를 가져옵니다.

public:
 property System::Web::UI::HtmlControls::HtmlHead ^ Header { System::Web::UI::HtmlControls::HtmlHead ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Web.UI.HtmlControls.HtmlHead Header { get; }
[<System.ComponentModel.Browsable(false)>]
member this.Header : System.Web.UI.HtmlControls.HtmlHead
Public ReadOnly Property Header As HtmlHead

속성 값

HtmlHead

페이지 헤더를 포함하는 HtmlHead입니다.

특성

예제

다음 코드 예제에서는 속성을 사용 하 여 프로그래밍 방식으로 컨트롤에 HtmlHead 액세스 하는 방법을 보여 줍니다 Header . title 요소와 style 요소가 페이지의 요소에 head 추가됩니다.

<%@ 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;

      // <Snippet2>
      // 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, null, "body");
      // </Snippet2>
 
      // Add the page title to the header element.
      Page.Header.Title = "HtmlHead Example"; 
                   
  }
  
</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>
<%@ 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

        ' <Snippet2>
        ' 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")
        ' </Snippet2>
            
        ' 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>

설명

이 속성은 Header 페이지에 대한 HtmlHead 문서 머리글 정보를 설정하는 데 사용할 수 있는 개체에 대한 참조를 가져옵니다. 스타일 HtmlHead 시트, 스타일 규칙, 제목 및 메타데이터와 같은 정보를 요소에 head 추가할 수 있습니다.

참고

비동기 포스트백 중에 인터페이스 메서드를 IStyleSheet 사용하여 프로그래밍 방식으로 스타일을 추가하는 것은 지원되지 않습니다. 웹 페이지에 AJAX 기능을 추가하는 경우 비동기 포스트백은 전체 페이지를 업데이트하지 않고 페이지의 영역을 업데이트합니다. 자세한 내용은 Microsoft Ajax Overview합니다.

적용 대상

추가 정보