Bewerken

Share via


HttpUtility.HtmlAttributeEncode Method

Definition

Minimally converts a string into an HTML-encoded string.

Overloads

HtmlAttributeEncode(String)

Minimally converts a string to an HTML-encoded string.

HtmlAttributeEncode(String, TextWriter)

Minimally converts a string into an HTML-encoded string and sends the encoded string to a TextWriter output stream.

HtmlAttributeEncode(String)

Source:
HttpUtility.cs
Source:
HttpUtility.cs
Source:
HttpUtility.cs

Minimally converts a string to an HTML-encoded string.

public:
 static System::String ^ HtmlAttributeEncode(System::String ^ s);
public static string? HtmlAttributeEncode (string? s);
public static string HtmlAttributeEncode (string s);
static member HtmlAttributeEncode : string -> string
Public Shared Function HtmlAttributeEncode (s As String) As String

Parameters

s
String

The string to encode.

Returns

An encoded string.

Remarks

The HtmlAttributeEncode method encodes characters appropriate for insertion into an HTML attribute value.

The string result from the HtmlAttributeEncode method should be used only for double-quoted attributes. Security issues might arise when using the HtmlAttributeEncode method with single-quoted attributes.

See also

Applies to

HtmlAttributeEncode(String, TextWriter)

Source:
HttpUtility.cs
Source:
HttpUtility.cs
Source:
HttpUtility.cs

Minimally converts a string into an HTML-encoded string and sends the encoded string to a TextWriter output stream.

public:
 static void HtmlAttributeEncode(System::String ^ s, System::IO::TextWriter ^ output);
public static void HtmlAttributeEncode (string? s, System.IO.TextWriter output);
public static void HtmlAttributeEncode (string s, System.IO.TextWriter output);
static member HtmlAttributeEncode : string * System.IO.TextWriter -> unit
Public Shared Sub HtmlAttributeEncode (s As String, output As TextWriter)

Parameters

s
String

The string to encode.

output
TextWriter

A TextWriter output stream.

Remarks

The HtmlAttributeEncode method converts only double quotation marks ("), single quotation marks ('), ampersands (&), and left angle brackets (<) to equivalent character entities. It is considerably faster than the HtmlEncode method.

The string result from the HtmlAttributeEncode method should be used only for double-quoted attributes. Security issues might arise when using the HtmlAttributeEncode method with single-quoted attributes.

See also

Applies to