HtmlEncode Method
Collapse the table of content
Expand the table of content

HttpUtility.HtmlEncode Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Converts a text string into an HTML-encoded string.

Namespace:  System.Net
Assembly:  System.Windows (in System.Windows.dll)

public static string HtmlEncode(
	string html
)

Parameters

html
Type: System.String
The text to HTML-encode.

Return Value

Type: System.String
An HTML-encoded string.

An HTML document consists of text and control characters. Control characters cannot be displayed directly unless they are HTML-encoded.

For example, to display the character < (less than sign) in your HTML document, you must use the character sequence &lt;. Otherwise, it will be interpreted as the beginning of an HTML tag.

This method performs the following conversions to character-entity equivalents:

  • < to &lt;

  • > to &gt;

  • & to &amp;

  • " to &quot;

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft