Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How to save html tags in sql server database? If i want to save HTML text to database, how can i do that?
Posted
Updated 10-Apr-21 7:01am

You can use the the HtmlEncode() and HtmlDecode() methods to convert the data before saving and retrieving data.

// Encode the content for storing in Sql server.
string htmlEncoded = WebUtility.HtmlEncode(text); 

// Decode the content for showing on Web page.
string original = WebUtility.HtmlDecode(htmlEncoded);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900