Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    406
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do I use Encoding, Decoding in asp.net?

    I have a url something like this (this is a fake url):

    http://www.mypage.aspx?aspx=B&K FunctionlGrp

    I wrote a code to get the CID and then display that CID in another page as it is. Since the CID has the '&' sign, whatever comes after the & sign is not displaying. How should I handle this with encoding, decoding in asp.net?

    Here is my partial code:

    string sCID = Request.QueryString["CID"];

    if (Request.QueryString["CID"] != null)
    {
    lnkHName = sCID;
    }
    else
    {
    //do something
    }

    I am displaying this lnkHName in a td tag and anything after & sign is lost. I looked at the www.w3schools.com website and they just give you all the encoding characters but dont explain how to do this in either VB.net or C#. Please help me. I use C# but vb also will help.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    406
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I found the answer

    Hi Guys,
    I found the answer for it. You have to use HttpUtility.UrlEncode before endcoding it and then you can use HttpUtility.UrlDecode to decode the characters.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •