HttpEncoder.HtmlAttributeEncode(String, TextWriter) Method

Definition

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.

protected internal virtual void HtmlAttributeEncode(string value, System.IO.TextWriter output);

Parameters

value
String

The string to encode.

output
TextWriter

The text writer to write the encoded value to.

Exceptions

output is null.

Remarks

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.

Applies to

Produkt Verze
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1