I 've been working on MOSS 2007 for the last year or so. Recently, while working on a dashboard, that integrates with Cognos, we realized that the query string parameters to the report were not getting encoded properly. Now I used all that is available in the .NET arsenal for encoding (viz.)
Uri.EscapeDataString, Uri.EscapeUriString, HttpUtility.UrlEncode, HttpUtility.UrlPathEncode, SPHttpUtility.UrlPathEncode etc. but nothing worked. Then we stumbled upon this excellent post by kaushik which educates on functions and methods present in Microsoft.Jscript.dll which allow the use of javascript functions like escape, encodeURI and encodeURIComponent directly within your .NET code. This post helped me trumendously. Thought to share it on my blog. Here's the URL
http://kseesharp.blogspot.com/2008/01/c-equivalent-of-javascript-escape.html
P.S. These methods may not work if you are using window.open function. This function does a decoding of its own before sending the URL out. So in call such cases, the workaround is to use target="_blank" to popup the url in a new window.....
Monday, April 21, 2008
Javascript functions in .NET
Labels:
encode,
encodeURI,
encodeURIComponent,
escape,
javascript,
jscript,
url
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment