Point Deep

Mundeep’s Tech Blog

How to Html Encode a string in a c# windows application?

Posted by mundeep on August 21, 2008

To HtmlEncode a string from within a Windows application you need to make sure that:

1) You have a reference to System.Web

2) You use the System.Web.HttpUtility.HtmlEncode method.

For example:

using System.Web;

public string MyHtmlEncode(string inputString) {
     return HttpUtility.HtmlEncode(inputString);
}

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>