how to store and retrieve the HTML text Editor contents to SQL Server DB in ASP.net C#

Nils picture Nils · Aug 22, 2013 · Viewed 22.7k times · Source

I am using a HMTL Text Editor in my asp.net with C# project. so, how do I store the editor contents in SQl Server 2008 DB so that it would be extracted as it is edited on the web page, means the same editing effects must be shown when I extract the data on a web page.

please Help

Thanks in Advance Nils

Answer

Kapil Khandelwal picture Kapil Khandelwal · Aug 22, 2013

You can use HtmlEncode & HtmlDecode:

// 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);