共用方式為


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)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

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