HtmlTextWriter.EncodeAttributeValue 메서드

정의

현재 컨텍스트의 HttpRequest 개체 요구 사항에 따라 지정된 태그 특성의 값을 인코딩합니다.

오버로드

EncodeAttributeValue(String, Boolean)

현재 컨텍스트의 HttpRequest 개체 요구 사항에 따라 지정된 태그 특성의 값을 인코딩합니다.

EncodeAttributeValue(HtmlTextWriterAttribute, String)

현재 컨텍스트의 HttpRequest 개체 요구 사항에 따라 지정된 태그 특성의 값을 인코딩합니다.

EncodeAttributeValue(String, Boolean)

현재 컨텍스트의 HttpRequest 개체 요구 사항에 따라 지정된 태그 특성의 값을 인코딩합니다.

protected:
 System::String ^ EncodeAttributeValue(System::String ^ value, bool fEncode);
protected string EncodeAttributeValue (string value, bool fEncode);
member this.EncodeAttributeValue : string * bool -> string
Protected Function EncodeAttributeValue (value As String, fEncode As Boolean) As String

매개 변수

value
String

인코딩할 특성 값을 포함하는 문자열입니다.

fEncode
Boolean

특성 값을 인코드하면 true이고, 인코드하지 않으면 false입니다.

반환

인코딩된 특성 값을 포함하는 문자열이거나, value가 비어 있으면 null이고, fEncode가 는 false이면 인코딩되지 않은 특성 값입니다.

예제

다음 코드 예제에서는 메서드 호출에서 매개 변수로 메서드를 호출 EncodeAttributeValueAddAttribute 다음 스타일 특성 값을 인코딩하는 color:blue 방법을 보여 줍니다.

// If the <label> element is rendered and a style
// attribute is not defined, add a style attribute 
// and set its value to blue.
if ( TagKey == HtmlTextWriterTag::Label )
{
   if (  !IsAttributeDefined( HtmlTextWriterAttribute::Style ) )
   {
      AddAttribute( "style", EncodeAttributeValue( "color:blue", true ) );
      Write( NewLine );
      Indent = 3;
      OutputTabs();
   }
}
// If the <label> element is rendered and a style
// attribute is not defined, add a style attribute 
// and set its value to blue.
if (TagKey == HtmlTextWriterTag.Label)
{
    if (!IsAttributeDefined(HtmlTextWriterAttribute.Style))
    {
        AddAttribute("style", EncodeAttributeValue("color:blue", true));
        Write(NewLine);
        Indent = 3;
        OutputTabs();
    }
}
' If the <label> element is rendered and a style
' attribute is not defined, add a style attribute 
' and set its value to blue.
If TagKey = HtmlTextWriterTag.Label Then
    If Not IsAttributeDefined(HtmlTextWriterAttribute.Style) Then
        AddAttribute("style", EncodeAttributeValue("color:blue", True))
        Write(NewLine)
        Indent = 3
        OutputTabs()
    End If
End If

설명

특성이 EncodeAttributeValueEncodeAttributeValue(HtmlTextWriterAttribute, String) 열거형 값이 아니 HtmlTextWriterAttribute 거나 런타임까지 알려지지 않은 경우 메서드의 오버로드를 사용합니다.

메서드는 EncodeAttributeValue 입력에 관계없이 잘못된 태그가 생성되지 않도록 큰따옴표("), 앰퍼샌드(&) 및 보다 작은 기호(<)를 제거합니다. 실제 인코딩은 메서드에 HtmlAttributeEncode 의해 수행됩니다.

추가 정보

적용 대상

EncodeAttributeValue(HtmlTextWriterAttribute, String)

현재 컨텍스트의 HttpRequest 개체 요구 사항에 따라 지정된 태그 특성의 값을 인코딩합니다.

protected:
 virtual System::String ^ EncodeAttributeValue(System::Web::UI::HtmlTextWriterAttribute attrKey, System::String ^ value);
protected virtual string EncodeAttributeValue (System.Web.UI.HtmlTextWriterAttribute attrKey, string value);
abstract member EncodeAttributeValue : System.Web.UI.HtmlTextWriterAttribute * string -> string
override this.EncodeAttributeValue : System.Web.UI.HtmlTextWriterAttribute * string -> string
Protected Overridable Function EncodeAttributeValue (attrKey As HtmlTextWriterAttribute, value As String) As String

매개 변수

attrKey
HtmlTextWriterAttribute

태그 특성을 나타내는 HtmlTextWriterAttribute입니다.

value
String

인코딩할 특성 값을 포함하는 문자열입니다.

반환

인코딩된 특성 값이 포함된 문자열입니다.

설명

메서드는 EncodeAttributeValue 입력에 관계없이 잘못된 태그가 생성되지 않도록 큰따옴표("), 앰퍼샌드(&) 및 보다 작은 기호(<)를 제거합니다. 실제 인코딩은 메서드에 HtmlAttributeEncode 의해 수행됩니다.

추가 정보

적용 대상