help to sole escape() + HttpUtility.UrlDecode problem

Last post 07-13-2009 8:02 AM by NC01. 7 replies.

Sort Posts:

  • help to sole escape() + HttpUtility.UrlDecode problem

    07-01-2009, 8:27 AM
    • Member
      10 point Member
    • jayason
    • Member since 09-22-2008, 4:31 AM
    • INDIA /KERALA
    • Posts 20

    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 use
    HttpUtility.UrlDecode(txtMessage.Text) to decode the text .But When i give  Ü  in
    text box and when i decode i am getting blank . why is it so .Also
     am not able to use \ ,^ etc ..


    JAYASON

    JSON
  • Re: help to sole escape() + HttpUtility.UrlDecode problem

    07-01-2009, 8:38 AM
    • All-Star
      77,517 point All-Star
    • NC01
    • Member since 08-26-2005, 7:33 PM
    • Posts 14,450
    • TrustedFriends-MVPs

     For all characters, try this:
    <script type="text/javascript">
    <!--
    var s = encodeURIComponent('sadadsdas+-');
    alert(s);
    var s2 = decodeURIComponent(s);
    alert(s2);
    // -->
    </script>

    NC...

     

  • Re: help to sole escape() + HttpUtility.UrlDecode problem

    07-01-2009, 8:53 AM
    • Member
      10 point Member
    • jayason
    • Member since 09-22-2008, 4:31 AM
    • INDIA /KERALA
    • Posts 20

    Thanks for your reply .But I need the decoding to be done in code not script . Can we do that.

    JSON
  • Re: help to sole escape() + HttpUtility.UrlDecode problem

    07-01-2009, 9:00 AM
    • All-Star
      77,517 point All-Star
    • NC01
    • Member since 08-26-2005, 7:33 PM
    • Posts 14,450
    • TrustedFriends-MVPs

    What do you mean? That is code.

    NC...

     

  • Re: help to sole escape() + HttpUtility.UrlDecode problem

    07-01-2009, 9:09 AM
    • Member
      10 point Member
    • jayason
    • Member since 09-22-2008, 4:31 AM
    • INDIA /KERALA
    • Posts 20

    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

    JSON
  • Re: help to sole escape() + HttpUtility.UrlDecode problem

    07-01-2009, 9:21 AM
    Answer
    • All-Star
      77,517 point All-Star
    • NC01
    • Member since 08-26-2005, 7:33 PM
    • Posts 14,450
    • TrustedFriends-MVPs

     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.

    NC...

     

  • Re: help to sole escape() + HttpUtility.UrlDecode problem

    07-11-2009, 5:44 AM
    • Participant
      881 point Participant
    • gavinharriss
    • Member since 03-05-2005, 8:07 AM
    • Posts 297

    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! :)

    Gavin Harriss
    Portfolio: www.gavinharriss.com
  • Re: help to sole escape() + HttpUtility.UrlDecode problem

    07-13-2009, 8:02 AM
    • All-Star
      77,517 point All-Star
    • NC01
    • Member since 08-26-2005, 7:33 PM
    • Posts 14,450
    • TrustedFriends-MVPs

    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

    NC...

     

Page 1 of 1 (8 items)