|
DailyCoding > General
|
How to Html Encode a string in .NET
|
| How to html encode a string in .net for displaying on a page |
|
Author
admin on
May 18, 2008 |
2 Comments
|
| Rate it |
|
(Rated
3
by
2
people)
|
 |
Loading.. |
|
926 Views
|
|
|
Html Encoding is basically converting Html tags in non Html tags so that they can
be embeded into a html code. Below code explains how rendering of a html string
may vary because of html encoding
string htmlString = "<b>Hello world!</b>";
Response.Write(htmlString);
// This will print: Hello world!
string htmlEncoded = Server.HtmlEncode(htmlString);
Response.Write(htmlEncoded);
// This will print: <b>Hello world!</b>
You may want to Html encode a string before showing any user input on the page
|
|
C#
|
Utility
|
|
|
|
|
|
|
Leave a Comment
|
 |
Loading.. |
|
|
|
|
|