there are generic problems with using url encode logic for this. url
encode is designed to encode a url, which has some ambiguous characters.
in a url no spaces are allowed, so a "+" is used instead. this means
there is no way in an encoded url to deteremine if a "+" is a plus or a
space. to solve this javascript has encodeURI and decodeURI which
handles this (spaces become %20, plus is left alone).
HttpUtility.UrlEncode converts spaces to "+" and "+" to %2b, so its not
compatible with decodeURI. you will have to write your own encoder.
the other approach is to store the data in a hidden field rather than a
javascript variable, then no decoding is required in javascript, and
HtmlEncode works correctly.
-- bruce (sqlwork.com)
Han wrote:
Hello
I am passing string from dotnet to javascript. ", ', newline characters, and
something. So I am using httputility.urlEncode() to make it neat.
Now a JS function accepts the encoded string and decode using decodeURI().
But still there are unsolved characters and some +, %, and hex numbers. What
is exact dotnet counterpart of JS decodeURI()?
I am not sure this matters. I am not using typical asp.net + JS. I am using
httputility.urlEncode() withinn XSL extension functions. I think that's not
related with my problem.
Thanks for your reading