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);

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>