HtmlHelper.AttributeEncode Method (Object)

Returns an HTML-encoded string that represents the specified object by using a minimal encoding that is suitable only for HTML attributes that are enclosed in quotation marks.

Namespace:  System.Web.WebPages.Html
Assembly:  System.Web.WebPages (in System.Web.WebPages.dll)


Public Function AttributeEncode ( _
    value As Object _
) As String
Dim instance As HtmlHelper 
Dim value As Object 
Dim returnValue As String 

returnValue = instance.AttributeEncode(value)
public string AttributeEncode(
    Object value
String^ AttributeEncode(
    Object^ value
member AttributeEncode : 
        value:Object -> string
public function AttributeEncode(
    value : Object
) : String


Return Value

Type: System.String
An HTML-encoded string that represents the object.


To facilitate encoding, the specified object is first converted to an unencoded string by calling its ToString method with the InvariantCulture enumeration. This string representation of the object is then encoded and returned.

Minimal HTML-encoding converts only double-quotation ("), ampersand (&), and less-than (<) characters to their corresponding HTML escape sequences. This is faster than full HTML encoding, but is suitable only for encoding HTML attributes that are in double quotation marks.

See Also


HtmlHelper Class

AttributeEncode Overload

System.Web.WebPages.Html Namespace