Reputation: 99
I am using textarea. This Textarea functionality is similar to Rich Text Box. My textarea has
<div style="width:100px;"><div style="height="400px;"></div></div>
In button click event I want to save this text in database table. But my coding saved like this
<div><div></div></div>
Upvotes: 0
Views: 2242
Reputation: 2145
Problem is you have to encode your code
using System;
using System.Net;
class Program
{
static void Main()
{
string a = WebUtility.HtmlEncode("<html><head><title>T</title></head></html>");
string b = WebUtility.HtmlDecode(a);
Console.WriteLine("After HtmlEncode: " + a);
Console.WriteLine("After HtmlDecode: " + b);
}
}
output
After HtmlEncode:
<html><head><title>T</title></head></html>
further read these articles
http://stackoverflow.com/questions/1144535/htmlencode-from-class-library
and
http://msdn.microsoft.com/en-us/library/w3te6wfz.aspx
and
http://www.dotnetperls.com/htmlencode-htmldecode
Upvotes: 1