HtmlForm.UniqueID 속성

정의

HtmlForm 컨트롤에 할당된 고유 프로그래밍 ID를 가져옵니다.

public:
 virtual property System::String ^ UniqueID { System::String ^ get(); };
public override string UniqueID { get; }
member this.UniqueID : string
Public Overrides ReadOnly Property UniqueID As String

속성 값

String

HtmlForm 컨트롤에 할당된 고유 프로그래밍 ID입니다.

예제

다음 코드 예제에서는 컨트롤에 UniqueID 대 한 HtmlForm 고유 식별자를 검색 하는 속성을 사용 하는 방법을 보여 줍니다.

<%@ 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 Button1_Click(object sender, System.EventArgs e)
  {
    
    // Write the form's UniqueID to the specified Label control.
    Label1.Text = "The HtmlForm control's UniqueID is "
                  + Form1.UniqueID + ".";
  }

  void Button2_Click(object sender, System.EventArgs e)
  {
    
    // Write the button's UniqueID to the specified Label control.
    Label2.Text = "This Button control's UniqueID is "
                 + Button2.UniqueID + ".";
  }
    
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head>

    <title>HtmlForm UniqueID Property Example</title>

</head>

<body>

    <form id="Form1"
          runat="server">
    
    <h3>HtmlForm UniqueID Property Example</h3>        
  
    <asp:button id="Button1"
                text="Get the form's UniqueID" 
                onclick="Button1_Click"
                runat="server">
    </asp:button>
    
    <asp:label id="Label1"
               runat="Server">
    </asp:label>
    
    <br />
    
    <asp:button id="Button2" 
                text="Get this button's UniqueID"
                onclick="Button2_Click"
                runat="server">
    </asp:button>

     
  
    <asp:label id="Label2"
               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 Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
  
    ' Write the form's UniqueID to the specified Label control.
    Label1.Text = "The HtmlForm control's UniqueID is " _
                  & Form1.UniqueID + "."
  End Sub
    
  Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
  
    ' Write the button's UniqueID to the specified Label control.
    Label2.Text = "This Button control's UniqueID is " _
                  & Button2.UniqueID & "."
  End Sub
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head>

    <title>HtmlForm UniqueID Property Example</title>

</head>

<body>

    <form id="Form1"
          runat="server">
    
    <h3>HtmlForm UniqueID Property Example</h3>        
  
    <asp:button id="Button1"
                text="Get the form's UniqueID" 
                onclick="Button1_Click"
                runat="server">
    </asp:button>
    
    <asp:label id="Label1"
               runat="Server">
    </asp:label>
    
    <br />
    
    <asp:button id="Button2" 
                text="Get this button's UniqueID"
                onclick="Button2_Click"
                runat="server">
    </asp:button>

    &nbsp    ;
  
    <asp:label id="Label2"
               runat="server">
    </asp:label>
    
  </form>

</body>

</html>

설명

UniqueID 속성을 사용하여 컨트롤에 할당된 HtmlForm 고유한 프로그래밍 식별자를 가져옵니다. 이 속성은 컨트롤이 사용자 지정 서버 컨트롤과 같은 페이지 이외의 구현된 개체에 INamingContainer포함된 경우 상수 값을 반환하도록 기본 구현을 재정의합니다. 명명 컨테이너가 페이지이면 컨트롤 ID 의 속성 값 HtmlForm 이 반환됩니다.

속성과 속성은 UniqueID Name 항상 동일한 값을 반환합니다. 컨트롤과 HtmlForm Name 속성이 동일해야 하는 브라우저에서 컨트롤 UniqueIDHtmlForm 렌더링할 때 유용합니다. 이러한 속성을 동기화된 상태로 유지하기 위해 속성은 Name 항상 속성 값을 반환합니다 UniqueID .

참고

이 특성은 name XHTML 규격 특성이 아니며 기본적으로 ASP.NET 렌더링되지 않습니다.

적용 대상

추가 정보