HtmlTextWriter.EncodeAttributeValue Method
.NET Framework 1.1
HTML encodes the specified HTML attribute's value.
Overload List
HTML encodes the specified HTML attribute's value.
[Visual Basic] Overloads Protected Overridable Function EncodeAttributeValue(HtmlTextWriterAttribute, String) As String
[C#] protected virtual string EncodeAttributeValue(HtmlTextWriterAttribute, string);
[C++] protected: virtual String* EncodeAttributeValue(HtmlTextWriterAttribute, String*);
[JScript] protected function EncodeAttributeValue(HtmlTextWriterAttribute, String) : String;
HTML encodes the specified HTML attribute's value.
[Visual Basic] Overloads Protected Function EncodeAttributeValue(String, Boolean) As String
[C#] protected string EncodeAttributeValue(string, bool);
[C++] protected: String* EncodeAttributeValue(String*, bool);
[JScript] protected function EncodeAttributeValue(String, Boolean) : String;
Example
[Visual Basic, C#, C++] Note This example shows how to use one of the overloaded versions of EncodeAttributeValue. For other examples that might be available, see the individual overload topics.
[Visual Basic] ' If the Label tag is being 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 [C#] // If the Label tag is being 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(); } } [C++] // If the Label tag is being 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(S"style", EncodeAttributeValue(S"color:blue", true)); Write(NewLine); Indent = 3; OutputTabs(); } }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
See Also
HtmlTextWriter Class | HtmlTextWriter Members | System.Web.UI Namespace