View Full Version : How do I use Encoding, Decoding in asp.net?

12-05-2006, 11:22 PM
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;
//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.

12-08-2006, 05:17 PM
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.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum