Sign in | Join
Last post 07-13-2009 8:02 AM by NC01. 7 replies.
Sort Posts: Oldest to newest Newest to oldest
I have a page in which i have a textbox. This textbox message is used in the code . But when i use some special chraters i get some error . So i wrote a javascript which encode the textvalue using escape() fuction. In the code secion i useHttpUtility.UrlDecode(txtMessage.Text) to decode the text .But When i give Ü intext box and when i decode i am getting blank . why is it so .Also am not able to use \ ,^ etc ..
JAYASON
For all characters, try this:<script type="text/javascript"><!--var s = encodeURIComponent('sadadsdas+-');alert(s);var s2 = decodeURIComponent(s);alert(s2);// --></script>
NC...
Thanks for your reply .But I need the decoding to be done in code not script . Can we do that.
What do you mean? That is code.
Ok .See we are doing the encoding in script which will be written in default.aspx . I need to write the decoding in default.aspx.cs , because i want to use that decoded values for some other purpose in default.aspx.cs . Thanks in advance
You can't encode it from the client-side and then decode it from the server-side and expect everything to work out right. Pick a side and do both from there.
A bit late, but handy for anyone else who stumbles across this thread looking for the solution...
The trick is to use encodeURIComponent instead of escape in the JavaScript! :)
gavinharriss: A bit late, but handy for anyone else who stumbles across this thread looking for the solution... The trick is to use encodeURIComponent instead of escape in the JavaScript! :)
I posted that already on 07-01-2009, 1:38 PM