SPHttpUtility.HtmlEncode method (String, TextWriter)

Encodes the specified string as a text string to be enclosed in HTML tags, or as an attribute value inside an HTML tag, and appends it to the specified output stream.

Namespace:  Microsoft.SharePoint.Utilities
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
Public Shared Sub HtmlEncode ( _
    valueToEncode As String, _
    output As TextWriter _
)
'Usage
Dim valueToEncode As String
Dim output As TextWriterSPHttpUtility.HtmlEncode(valueToEncode, output)
public static void HtmlEncode(
    string valueToEncode,
    TextWriter output
)

Parameters

  • output
    Type: System.IO.TextWriter

    A T:System.IO.TextWriter object that represents the output stream to which to add the encoded string.

Remarks

This method escapes the ampersand (&), double-quote (“), single-quote (‘), less-than (<), and greater-than (>) characters in the valueToEncode parameter with the appropriate entity references before and appends the result to the output stream as specified by the output parameter.

See also

Reference

SPHttpUtility class

SPHttpUtility members

HtmlEncode overload

Microsoft.SharePoint.Utilities namespace