Question

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

Was it helpful?

Solution

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

OTHER TIPS

I think that it would be SQL injection if you enter data like this . Data coming from user input should always be checked and before sending to the database.

Using ASP.NET you need to remove all HTML tags from the post back because the framework checks for possible HTML injection coming from the user input .

After removing the tags (or replacing the < by something like < and necessary symbols also ) and converting back in the server when viewing data.

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

Refer posts it may help you

How to save HTML content in database

http://forums.asp.net/t/1441293.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top