共用方式為


SPHttpUtility.HtmlUrlAttributeEncode Method (String)

Encodes the specified string for use as an attribute value for URL type attributes, such as the href attribute of an anchor tag or the src attribute of an image tag.

Namespace:  Microsoft.SharePoint.Utilities
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

Syntax

'Declaration
Public Shared Function HtmlUrlAttributeEncode ( _
    urlAttributeToEncode As String _
) As String
'Usage
Dim urlAttributeToEncode As String
Dim returnValue As String

returnValue = SPHttpUtility.HtmlUrlAttributeEncode(urlAttributeToEncode)
public static string HtmlUrlAttributeEncode(
    string urlAttributeToEncode
)

Parameters

Return Value

Type: System.String
The encoded string.

Remarks

The HtmlUrlAttributeEncode method checks the URL protocol and, if the URL is relative or has an allowed protocol, encodes the string for use as an attribute value. It does not encode the path or query string of the URL. If you are building a URL, call UrlPathEncode and UrlKeyValueEncode separately before you call this method.

See Also

Reference

SPHttpUtility Class

SPHttpUtility Members

HtmlUrlAttributeEncode Overload

Microsoft.SharePoint.Utilities Namespace