HtmlHead 생성자

정의

HtmlHead 클래스의 새 인스턴스를 초기화합니다.

오버로드

HtmlHead()

HtmlHead 클래스의 새 인스턴스를 초기화합니다.

HtmlHead(String)

지정된 태그를 사용하여 HtmlHead 클래스의 새 인스턴스를 초기화합니다.

HtmlHead()

HtmlHead 클래스의 새 인스턴스를 초기화합니다.

public:
 HtmlHead();
public HtmlHead ();
Public Sub New ()

예제

다음 예제에서는 프로그래밍 방식으로 추가 하는 방법을 보여 줍니다는 HtmlHead 컨트롤을 페이지 및 추가 titlelink 를 요소입니다.

<%@ 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">  
  
  void Page_Load(object sender, System.EventArgs e)
  {

    // Programmatically create an HtmlHead control.
    HtmlHead head = new HtmlHead();

    // Add the page title to the header element.
    HtmlTitle title = new HtmlTitle();
    title.Text = "HtmlHead Constructor Example";
    head.Controls.Add(title);

    // Add a defined style sheet that contains the body
    // style to the HtmlHead control.
    HtmlLink link = new HtmlLink();
    link.Href = "~/Stylesheet.css";
    link.Attributes.Add("rel", "stylesheet");
    link.Attributes.Add("type", "text/css");
    head.Controls.Add(link);

    // Add the HtmlHead controls to the Controls
    // collection of the page.
    Page.FindControl("HtmlElement").Controls.AddAt(0, head);

  }
  
</script>

<html id="HtmlElement" 
      runat="server" 
      xmlns="http://www.w3.org/1999/xhtml" >

<body>
  <form id="form1" runat="server">
  
  <h3>HtmlHead Class Constructor Example </h3>
        
  <hr />
    
  <asp:label id="Label1" 
    text = "View the HTML source code of this page to see the title 
            and style sheet link 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">
  
  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

    ' Programmatically create an HtmlHead control.
    Dim head As New HtmlHead()

    ' Add the page title to the header element.
    Dim title As New HtmlTitle()
    title.Text = "HtmlHead Constructor Example"
    head.Controls.Add(title)

    ' Add a defined style sheet that contains the body
    ' style to the HtmlHead control.
    Dim link As New HtmlLink()
    link.Href = "~/Stylesheet.css"
    link.Attributes.Add("rel", "stylesheet")
    link.Attributes.Add("type", "text/css")
    head.Controls.Add(link)

    ' Add the HtmlHead controls to the Controls
    ' collection of the page.
    Page.FindControl("HtmlElement").Controls.AddAt(0, head)
    
  End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml"  id="HtmlElement"
      runat="server">

<body>
  <form id="form1" runat="server">
  
  <h3>HtmlHead Class Constructor Example </h3>
        
  <hr />
    
  <asp:label id="Label1" 
    text = "View the HTML source code of this page to see the title 
            and style sheet link added to the header element."
    runat="server">
  </asp:label>   
        
  </form>
</body>
</html>

설명

다음 표에서 인스턴스에 대 한 초기 속성 값을 HtmlHead입니다.

속성 초기 값
TagName "Head" 문자열입니다.

추가 정보

적용 대상

HtmlHead(String)

지정된 태그를 사용하여 HtmlHead 클래스의 새 인스턴스를 초기화합니다.

public:
 HtmlHead(System::String ^ tag);
public HtmlHead (string tag);
new System.Web.UI.HtmlControls.HtmlHead : string -> System.Web.UI.HtmlControls.HtmlHead
Public Sub New (tag As String)

매개 변수

tag
String

컨트롤의 태그 이름을 지정하는 문자열입니다.

설명

다음 표에서 인스턴스에 대 한 초기 속성 값을 HtmlHead입니다.

속성 초기 값
TagName tag 매개 변수의 값입니다.

적용 대상