HtmlTextWriter.GetAttributeKey(String) 메서드

정의

지정된 특성에 해당하는 HtmlTextWriterAttribute 열거형 값을 가져옵니다.

protected:
 System::Web::UI::HtmlTextWriterAttribute GetAttributeKey(System::String ^ attrName);
protected System.Web.UI.HtmlTextWriterAttribute GetAttributeKey (string attrName);
member this.GetAttributeKey : string -> System.Web.UI.HtmlTextWriterAttribute
Protected Function GetAttributeKey (attrName As String) As HtmlTextWriterAttribute

매개 변수

attrName
String

HtmlTextWriterAttribute를 가져올 특성이 포함된 문자열입니다.

반환

HtmlTextWriterAttribute

지정된 특성에 대한 HtmlTextWriterAttribute 열거형 값이거나, 해당 특성이 열거형의 멤버가 아닌 경우에는 잘못된 HtmlTextWriterAttribute 값입니다.

예제

다음 코드 예제에서는 메서드를 재정의 HtmlTextWriter 하는 클래스에서 파생 된 클래스를 RenderBeginTag 사용 하는 방법을 보여 줍니다. 재정의는 태그 요소가 렌더링될 것임을 나타내는 필드와 <font> 같은 Font 지 여부를 tagKey 확인합니다. 이 경우 재정의는 메서드를 IsAttributeDefined 호출하여 요소에 특성이 <font> 포함되어 있는지 여부를 확인합니다 Size . 반환false되는 IsAttributeDefined 경우 메서드는 AddAttribute 메서드를 GetAttributeKey 호출합니다. Size 메서드는 해당 값을 정의하고 해당 값을 .로 30pt설정합니다.

// If the tagKey parameter is set to a <font> element
// but a size attribute is not defined on the element,
// the AddStyleAttribute method adds a size attribute
// and sets it to 30 point.
if ( tagKey == HtmlTextWriterTag::Font )
{
   if (  !IsAttributeDefined( HtmlTextWriterAttribute::Size ) )
   {
      AddAttribute( GetAttributeKey( "size" ), "30pt" );
   }
}
// If the tagKey parameter is set to a <font> element
// but a size attribute is not defined on the element,
// the AddStyleAttribute method adds a size attribute
// and sets it to 30 point. 
if (tagKey == HtmlTextWriterTag.Font)
{
    if (!IsAttributeDefined(HtmlTextWriterAttribute.Size))
    {
        AddAttribute(GetAttributeKey("size"), "30pt");
    }
}
' If the tagKey parameter is set to a <font> element
' but a size attribute is not defined on the element,
' the AddStyleAttribute method adds a size attribute
' and sets it to 30 point. 
If tagKey = HtmlTextWriterTag.Font Then
    If Not IsAttributeDefined(HtmlTextWriterAttribute.Size) Then
        AddAttribute(GetAttributeKey("size"), "30pt")
    End If
End If

설명

null 특성 이름 테이블에서 빈 문자열("")이거나 찾을 수 없는 경우 attrName 개체에 입력된 HtmlTextWriterAttribute -1 값이 반환됩니다.

적용 대상

추가 정보