SharePoint 2007: Escaping URLs for CTX object

I keep coming across URLs in the following format \u002fmyweb\u002fshared\u002520Documents (especially within ctx JavaScript objects).
To encode URLs in this format, use the following function (note you will need to refer to the Microsoft.SharePoint.Utilities namespace):

public string EscapeUrlForCtx(string inputUrl)
{
string escapedUrl = SPEncode.URLEncode(inputUrl);
return SPEncode.ScriptEncode(escapedUrl);
}

You May Also Like

About the Author: rnowik

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.