HtmlHelper.Encode Method

Include Protected Members
Include Inherited Members

Returns an HTML-encoded string by using a full encoding that is suitable for arbitrary HTML.

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

Overload List

  Name Description
Public method Encode(Object) Returns an HTML-encoded string that represents the specified object by using a full encoding that is suitable for arbitrary HTML.
Public method Encode(String) Returns an HTML-encoded string that represents the specified string by using a full encoding that is suitable for arbitrary HTML.

Top

Remarks

Full HTML encoding ensures that the encoded text is not interpreted by the browser as HTML markup. For example, if a string contains the less than (<) or greater than (>) characters, and if it is written to an HTTP response before it is encoded, these characters will be interpreted by the browser as opening and closing an HTML element tag. By using the Encode(String) method to encode these symbols to their HTML escape sequences ("&lt;" and "&gt;"), you make sure that these characters are interpreted as text instead of markup and that they are displayed on the web page using the less than (<) and greater than (>) characters.

See Also

Reference

HtmlHelper Class

System.Web.WebPages.Html Namespace