Share via


HtmlHelper.AttributeEncode Method (String)

Converts the specified attribute string to an HTML-encoded string.

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

Syntax

'Declaration
Public Function AttributeEncode ( _
    value As String _
) As String
public string AttributeEncode(
    string value
)
public:
String^ AttributeEncode(
    String^ value
)

Parameters

Return Value

Type: System.String
The HTML-encoded string. If the value parameter is null reference (Nothing in Visual Basic) or empty, this method returns an empty string.

Remarks

The AntiForgeryToken method converts quotation marks ("), ampersands (&), and left angle brackets (<) to equivalent character entities.

The result should be used only for attributes that are in double quotation marks. Security issues might arise if you use the AntiForgeryToken method to encode attributes that are in single quotation marks.

See Also

Reference

HtmlHelper Class

AttributeEncode Overload

System.Web.Mvc Namespace