Sponsored Ad

Monday, December 28, 2009

Using HTML Decode with C# string

You can easily encode and decode string in c#. There is Microsoft library function that you can use to decode.

You can not directly pass everything in URL. Like url string only accepts ?, & and / . so you need to encode it before passing to the browser and after that you need to decode it to properly use.

Also if you will try to store raw url in database, It will prompt an error message. one way is to encode the given url and store it.

After encoding you need a url in original form. So use the following methods to decode url/string.

Sample encoding code is as follows:

 

Code Snippet
  1. string result = System.Web.HttpUtility.HtmlDecode(“Sample string”);
  2. // other method
  3. Server.HtmlDecode(TestString)

0 comments:

Post a Comment

Sponsored Ad

More Related Articles

Website Update

Followers