HtmlHelper.Encode Method

 

Converts the specified value to an HTML-encoded string.

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

NameDescription
System_CAPS_pubmethodEncode(Object)

Converts the value of the specified object to an HTML-encoded string.

System_CAPS_pubmethodEncode(String)

Converts the specified string to an HTML-encoded string.

Return to top

HtmlHelper.Encode Method (Object)

Converts the value of the specified object to an HTML-encoded string.

public string Encode(
	object value
)

Parameters

value
Type: System.Object

The object to encode.

Return Value

Type: System.String

The HTML-encoded string.

If characters such as spaces and punctuation are passed in an HTTP stream, they can be misinterpreted when they are processed. URL encoding converts characters that are not allowed in a URL into character-entity equivalents. For example, when the characters < and > are embedded in a block of text to be transmitted in a URL, they are encoded as %3c and %3e.

Return to top

HtmlHelper.Encode Method (String)

Converts the specified string to an HTML-encoded string.

public string Encode(
	string value
)

Parameters

value
Type: System.String

The string to encode.

Return Value

Type: System.String

The HTML-encoded string.

If characters such as spaces and punctuation are passed in an HTTP stream, they can be misinterpreted when they are processed. URL encoding converts characters that are not allowed in a URL into character-entity equivalents. For example, when the characters < and > are embedded in a block of text to be transmitted in a URL, they are encoded as %3c and %3e.

Return to top
Show: