HtmlTextWriter.OnTagRender(String, HtmlTextWriterTag) 메서드

정의

지정된 태그 요소가 요청 페이지에 렌더링될지 여부를 결정합니다.

protected:
 virtual bool OnTagRender(System::String ^ name, System::Web::UI::HtmlTextWriterTag key);
protected virtual bool OnTagRender(string name, System.Web.UI.HtmlTextWriterTag key);
abstract member OnTagRender : string * System.Web.UI.HtmlTextWriterTag -> bool
override this.OnTagRender : string * System.Web.UI.HtmlTextWriterTag -> bool
Protected Overridable Function OnTagRender (name As String, key As HtmlTextWriterTag) As Boolean

매개 변수

name
String

렌더링할 요소의 이름을 포함하는 문자열입니다.

key
HtmlTextWriterTag

HtmlTextWriterTag 요소와 연결된 요소입니다.

반품

항상 true입니다.

예제

다음 코드 예제에서는 메서드를 재정의 OnTagRender 하는 방법을 보여줍니다. Font 요소가 렌더링되는 경우 재정의 OnTagRender 는 메서드를 IsAttributeDefined 사용하여 특성이 Size 렌더링되는지 여부를 확인합니다. 그렇지 않은 경우 메서드를 AddAttribute 사용하여 특성을 만들고 Size 해당 값을 20pt.로 설정합니다.

// If a <font> element is to be rendered, check whether it contains
// a size attribute. If it does not, add one and set its value to
// 20 points, then return true.
protected override bool OnTagRender(string name, HtmlTextWriterTag key)
{

    if (key == HtmlTextWriterTag.Font)
    {
        if (!(IsAttributeDefined(HtmlTextWriterAttribute.Size)))
        {
            AddAttribute(HtmlTextWriterAttribute.Size, "20pt");
            return true;
        }
    }

    // If the element is not a <font> element, use
    // the base functionality of the OnTagRenderMethod.
    return base.OnTagRender(name, key);
}
' If a <font> element is to be rendered, check whether it contains
' a size attribute. If it does not, add one and set its value to
' 20 points, then return true.
Protected Overrides Function OnTagRender( _
    name As String, _
    key As HtmlTextWriterTag) _
As Boolean

    If (key = HtmlTextWriterTag.Font) Then
        If Not (IsAttributeDefined(HtmlTextWriterAttribute.Size)) Then
            AddAttribute(HtmlTextWriterAttribute.Size, "20pt")
            Return True
        End If
    End If

    ' If the element is not a <font> element, use
    ' the base functionality of the OnTagRenderMethod.
    Return MyBase.OnTagRender(name, key)
End Function

설명

메서드의 HtmlTextWriter 클래스 구현은 OnTagRender 항상 .true 재정의는 OnTagRender 요소를 페이지에 렌더링할지 여부를 결정할 수 있습니다.

상속자 참고

클래스에서 상속하는 HtmlTextWriter 경우 태그 요소가 전혀 렌더링되지 않도록 또는 특정 태그 언어에 대해 반환 OnTagRender(String, HtmlTextWriterTag) 하도록 메서드를 재정 false 의할 수 있습니다. 예를 들어 파생된 HtmlTextWriter 개체가 요소를 렌더링 <font> 하지 않도록 하려면 요소를 포함하는 OnTagRender(String, HtmlTextWriterTag) 페이지가 요청될 때 반환 false 할 메서드를 재정 <font> 의할 수 있습니다.

적용 대상

추가 정보