HtmlTextWriter.OnStyleAttributeRender 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 태그 스타일 특성과 해당 값을 현재 태그 요소에 렌더링할 수 있는지 여부를 결정합니다.
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
스타일 특성에 할당된 값을 포함하는 문자열입니다.
HtmlTextWriterStyle 스타일 특성과 연결된 특성입니다.
반품
항상 true입니다.
예제
다음 코드 예제에서는 메서드를 재정의 OnStyleAttributeRender 하는 방법을 보여줍니다.
Color 스타일 특성이 렌더링되지만 Color 값이 아닌 purple경우 재정의 OnStyleAttributeRender 는 메서드를 AddStyleAttribute 사용하여 특성을 Color설정합니다purple.
// 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
설명
메서드의 HtmlTextWriter 클래스 구현은 OnStyleAttributeRender 항상 .true 재정의는 OnStyleAttributeRender 스타일 특성이 페이지에 렌더링되는지 여부를 결정할 수 있습니다.
상속자 참고
클래스에서 HtmlTextWriter 상속하는 경우 스타일 특성이 전혀 렌더링되거나, 특정 요소에 렌더링되거나, 특정 태그 언어로 렌더링되지 않도록 반환 OnStyleAttributeRender(String, String, HtmlTextWriterStyle) 하도록 메서드를 재정 false 의할 수 있습니다. 예를 들어 스타일 특성을 HtmlTextWriter 요소에 렌더링 color 하기 위해 파생된 <p> 개체를 사용하지 않으려면 전달 OnStyleAttributeRender(String, String, HtmlTextWriterStyle)false 시 재정의 name 하고 속성 값이 반환 colorTagName 될 p수 있습니다.