HtmlTextWriter.OnStyleAttributeRender 메서드

정의

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

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

매개 변수

name
String

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

value
String

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

key
HtmlTextWriterStyle

스타일 특성과 관련된 HtmlTextWriterStyle입니다.

반환

Boolean

항상 true입니다.

예제

다음 코드 예제에서는 메서드를 재정의 OnStyleAttributeRender 하는 방법을 보여줍니다. Color 스타일 특성이 렌더링되지만 Color 값이 아닌 purple경우 재정의 OnStyleAttributeRender 는 메서드를 AddStyleAttribute 사용하여 특성을 purple.로 설정합니다Color.

// If a color style attribute is to be rendered,
// compare its value to purple. If it is not set to
// purple, add the style attribute and set the value
// to purple, then return false.
protected override bool OnStyleAttributeRender(string name,
    string value,
    HtmlTextWriterStyle key)
{

    if (key == HtmlTextWriterStyle.Color)
    {
        if (string.Compare(value, "purple") != 0)
        {
            AddStyleAttribute("color", "purple");
            return false;
        }
    }

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

    If key = HtmlTextWriterStyle.Color Then
        If [String].Compare(value, "purple") <> 0 Then
            AddStyleAttribute("color", "purple")
            Return False
        End If
    End If

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

설명

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

상속자 참고

클래스에서 HtmlTextWriter 상속하는 경우 스타일 특성이 전혀 렌더링되거나, 특정 요소에서 렌더링되거나, 특정 태그 언어에 대해 렌더링되지 않도록 반환 false 하도록 메서드를 재정 OnStyleAttributeRender(String, String, HtmlTextWriterStyle) 의할 수 있습니다. 예를 들어 파생된 HtmlTextWriter 개체를 요소에 스타일 특성을 <p> 렌더링 color 하지 않으려면 전달 color TagName 시 재정의 OnStyleAttributeRender(String, String, HtmlTextWriterStyle) 하고 속성 값이 반환 false namep수 있습니다.

적용 대상

추가 정보