HtmlTextWriter.TagName 속성

정의

렌더링되는 태그 요소의 태그 이름을 가져오거나 설정합니다.

protected:
 property System::String ^ TagName { System::String ^ get(); void set(System::String ^ value); };
protected string TagName { get; set; }
member this.TagName : string with get, set
Protected Property TagName As String

속성 값

String

렌더링되는 태그 요소의 태그 이름입니다.

예제

다음 코드 예제에서는 클래스에서 HtmlTextWriter 파생 되는 클래스에서 RenderBeforeTag 메서드의 재정의 된 버전을 보여 줍니다. 이 코드 예제에서는 메서드를 호출 String.Compare 한 다음 속성 값과 문자열"label"<label> 매개 변수 인수로 전달 TagName 하여 렌더링할 요소가 요소인지 여부를 확인합니다. <label> 요소를 렌더링하려고 하면 특성이 설정된 red요소 color<font> 여는 태그가 요소의 여는 태그 앞에 <label> 렌더링됩니다. 렌더링할 요소가 요소가 아니면 <label> 기본 클래스의 RenderBeforeTag 메서드 버전이 호출됩니다.

// Override the RenderBeforeTag method to add the
// opening tag of a Font element before the
// opening tag of any Label elements rendered by this
// custom markup writer.
virtual String^ RenderBeforeTag() override
{
   // Compare the TagName property value to the
   // String* label to determine whether the element to
   // be rendered is a Label. If it is a Label,
   // the opening tag of the Font element, with a Color
   // style attribute set to red, is added before
   // the Label.
   if ( String::Compare( TagName, "label" ) == 0 )
   {
      return "<font color=\"red\">";
   }
   // If a Label is not being rendered, use
   // the base RenderBeforeTag method.
   else
   {
      return __super::RenderBeforeTag();
   }
}
// Override the RenderBeforeTag method to add the 
// opening tag of a Font element before the 
// opening tag of any Label elements rendered by this 
// custom markup writer. 
protected override string RenderBeforeTag()
{
    // Compare the TagName property value to the
    // string label to determine whether the element to 
    // be rendered is a Label. If it is a Label,
    // the opening tag of the Font element, with a Color
    // style attribute set to red, is added before
    // the Label.
    if (String.Compare(TagName, "label") == 0)
    {
        return "<font color=\"red\">";
    }
    // If a Label is not being rendered, use 
        // the base RenderBeforeTag method.
    else
    {
        return base.RenderBeforeTag();
    }
}
' Override the RenderBeforeTag method to add the 
' opening tag of a Font element before the 
' opening tag of any Label elements rendered by this 
' custom markup writer. 
Protected Overrides Function RenderBeforeTag() As String
    ' Compare the TagName property value to the
    ' string label to determine whether the element to 
    ' be rendered is a Label. If it is a Label,
    ' the opening tag of the Font element, with a Color
    ' style attribute set to red, is added before
    ' the Label.
    If String.Compare(TagName, "label") = 0 Then
        Return "<font color=""red"">"
        ' If a Label is not being rendered, use 
        ' the base RenderBeforeTag method.
    Else
        Return MyBase.RenderBeforeTag()
    End If
End Function 'RenderBeforeTag

설명

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

적용 대상

추가 정보