HtmlTextWriter.OnAttributeRender 메서드

정의

지정된 태그 특성과 그 값이 현재 태그 요소로 렌더링될 수 있는지 여부를 결정합니다.

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

매개 변수

name
String

렌더링할 특성의 이름이 포함된 문자열입니다.

value
String

특성에 할당되는 값이 포함된 문자열입니다.

key
HtmlTextWriterAttribute

태그 특성과 관련된 HtmlTextWriterAttribute입니다.

반환

Boolean

항상 true입니다.

예제

다음 코드 예제에서는 메서드를 재정의 OnAttributeRender 하는 방법을 보여줍니다. 특성이 Size 렌더링되지만 값이 아닌 30pt경우 재정의 Size OnAttributeRender 는 메서드를 AddAttribute 호출하여 특성을 추가하고 Size 해당 값을 .30pt로 설정합니다.

// If a size attribute is to be rendered, compare its value to 30 point.
// If it is not set to 30 point, add the attribute and set the value to 30,
// then return false.
protected override bool OnAttributeRender(string name,
    string value,
    HtmlTextWriterAttribute key)
{

    if (key == HtmlTextWriterAttribute.Size)
    {
        if (string.Compare(value, "30pt") != 0)
        {
            AddAttribute("size", "30pt");
            return false;
        }
    }

    // If the attribute is not a size attribute, use
    // the base functionality of the OnAttributeRender method.
    return base.OnAttributeRender(name, value, key);
}
' If a size attribute is to be rendered, compare its value to 30 point.
' If it is not set to 30 point, add the attribute and set the value to 30
' then return false.
Protected Overrides Function OnAttributeRender(name As String, _
    value As String, _
    key As HtmlTextWriterAttribute) _
As Boolean

    If key = HtmlTextWriterAttribute.Size Then
        If [String].Compare(value, "30pt") <> 0 Then
            AddAttribute("size", "30pt")
            Return False
        End If
    End If

    ' If the attribute is not a size attribute, use
    ' the base functionality of the OnAttributeRender method.
    Return MyBase.OnAttributeRender(name, value, key)
End Function 'OnAttributeRender

설명

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

상속자 참고

클래스에서 HtmlTextWriter 상속하는 경우 특성이 전혀 렌더링되거나, 특정 요소에서 렌더링되거나, 특정 태그에 대해 렌더링되지 않도록 반환 false 하도록 메서드를 재정 OnAttributeRender(String, String, HtmlTextWriterAttribute) 의할 수 있습니다. 예를 들어 특성을 요소에 렌더링 bgcolor <table> 하기 위해 파생된 HtmlTextWriter 개체를 원하지 않는 경우 전달 TagName bgcolor 시 재정의 OnAttributeRender(String, String, HtmlTextWriterAttribute) 하고 속성 false name 값이 반환될 table수 있습니다.

적용 대상

추가 정보