HtmlTextWriter.TagKey 속성

정의

지정된 태그 요소의 HtmlTextWriterTag 값을 가져오거나 설정합니다.

protected:
 property System::Web::UI::HtmlTextWriterTag TagKey { System::Web::UI::HtmlTextWriterTag get(); void set(System::Web::UI::HtmlTextWriterTag value); };
protected System.Web.UI.HtmlTextWriterTag TagKey { get; set; }
member this.TagKey : System.Web.UI.HtmlTextWriterTag with get, set
Protected Property TagKey As HtmlTextWriterTag

속성 값

HtmlTextWriterTag

여는 태그를 렌더링하는 태그 요소입니다.

예외

속성 값이 설정될 수 없는 경우

예제

다음 코드 예제에서는 클래스에서 HtmlTextWriter 파생 되는 클래스에서 RenderBeforeContent 메서드의 재정의 된 버전을 보여 줍니다. 속성 값을 TagKey 사용하여 사용자 지정 HtmlTextWriter 개체를 사용하는 서버 컨트롤이 태그 요소를 렌더링하는지 <label> 여부를 확인합니다. 이 경우 특성이 <font> 설정된 red 요소가 color 반환되어 요소 텍스트의 <label> 서식을 수정합니다.

// Override the RenderBeforeContent method to write
// a font element that applies red to the text in a Label element.

virtual String^ RenderBeforeContent() override
{
   
   // Check to determine whether the element being rendered
   // is a label element. If so, render the opening tag
   // of the font element; otherwise, call the base method.
   if ( TagKey == HtmlTextWriterTag::Label )
   {
      return "<font color=\"red\">";
   }
   else
   {
      return __super::RenderBeforeContent();
   }
}
// Override the RenderBeforeContent method to write
// a font element that applies red to the text in a Label element.
protected override string RenderBeforeContent()
{
    // Check to determine whether the element being rendered
    // is a label element. If so, render the opening tag
    // of the font element; otherwise, call the base method.
    if (TagKey == HtmlTextWriterTag.Label)
    {
        return "<font color=\"red\">";
    }
    else
    {
        return base.RenderBeforeContent();
    }
}
' Override the RenderBeforeContent method to write
' a font element that applies red to the text in a Label element.
Protected Overrides Function RenderBeforeContent() As String
    ' Check to determine whether the element being rendered
    ' is a label element. If so, render the opening tag
    ' of the font element; otherwise, call the base method.
    If TagKey = HtmlTextWriterTag.Label Then
        Return "<font color=""red"">"
    Else
        Return MyBase.RenderBeforeContent()
    End If
End Function 'RenderBeforeContent

설명

TagKey 속성은 클래스에서 HtmlTextWriter 상속되는 클래스에만 사용됩니다. 메서드 호출 RenderBeginTag 에서만 속성을 읽거나 설정 TagKey 해야 합니다. 이때만 일관된 값으로 설정됩니다.

적용 대상

추가 정보