HttpUtility.UrlKeyValueEncode Method (String, String, TextWriter)
Encodes a string key and value for use in a URL query string, and then appends it to the specified output stream.
Namespace: Microsoft.SharePoint.Client.Utilities
Assembly: Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)
Syntax
'Declaration
Public Shared Sub UrlKeyValueEncode ( _
keyToEncode As String, _
valueToEncode As String, _
output As TextWriter _
)
'Usage
Dim keyToEncode As String
Dim valueToEncode As String
Dim output As TextWriterHttpUtility.UrlKeyValueEncode(keyToEncode, _
valueToEncode, output)
public static void UrlKeyValueEncode(
string keyToEncode,
string valueToEncode,
TextWriter output
)
Parameters
keyToEncode
Type: System.StringThe key string to be encoded.
valueToEncode
Type: System.StringThe value string to be encoded.
output
Type: System.IO.TextWriterA TextWriter object that represents the output stream to which to add the encoded key or value.
Remarks
Use the UrlKeyValueEncode(Guid) method to encode a URL that you are constructing instead of passing an existing URL, for example, a URL that was entered by the user.
To encode the specified string for use as an attribute value for URL type attributes, use the HtmlUrlAttributeEncode() method.
To encode an HTML string, use the HtmlEncode(String) method.
This method renders the '=' character along with the encoded key and value string to the output stream. However, you still need to render the '?' and '&' characters yourself.