HtmlTextWriter.EncodeAttributeValue 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
현재 컨텍스트의 개체 요구 사항에 따라 지정된 태그 특성의 HttpRequest 값을 인코딩합니다.
오버로드
| Name | Description |
|---|---|
| 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
반품
인코딩된 특성 값이 null 들어 있는 문자열(비어 있는 경우 value ) 또는 인코딩되지 않은 특성 값(있는 경우 fEncode )입니다 false.
예제
다음 코드 예제에서는 메서드 호출에서 메서드를 매개 변수로 호출 EncodeAttributeValue 한 AddAttribute 다음 스타일 특성 값을 인코딩하는 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
설명
특성이 EncodeAttributeValue 열거형 값이 아니 EncodeAttributeValue(HtmlTextWriterAttribute, String) 거나 런타임까지 알려지지 않은 경우 메서드의 오버로드 HtmlTextWriterAttribute 를 사용합니다.
이 메서드는 EncodeAttributeValue 입력에 관계없이 잘못된 태그가 생성되지 않도록 큰따옴표("), 앰퍼샌드(&A) 및 보다 작은 기호(<)를 제거합니다. 실제 인코딩은 메서드에 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 입력에 관계없이 잘못된 태그가 생성되지 않도록 큰따옴표("), 앰퍼샌드(&A) 및 보다 작은 기호(<)를 제거합니다. 실제 인코딩은 메서드에 HtmlAttributeEncode 의해 수행됩니다.