HttpEncoder.HtmlAttributeEncode Method (String, TextWriter)

.NET Framework (current version)

Encodes an incoming value into a string that can be inserted into an HTML attribute that is delimited by using single or double quotation marks.

Namespace:   System.Web.Util
Assembly:  System.Web (in System.Web.dll)

protected internal virtual void HtmlAttributeEncode(
	string value,
	TextWriter output


Type: System.String

The string to encode.

Type: System.IO.TextWriter

The text writer to write the encoded value to.

Exception Condition

output is null.

The HtmlAttributeEncode method encodes characters by using the standard HTML entities. For example, the < (left angle bracket) is encoded as &lt; and the \ (backslash) is encoded as &#92;.

It is safe to use HtmlAttributeEncode within single-quoted and double-quoted attributes. The values must be quoted.

.NET Framework
Available since 4.0
Return to top