hi Ganesh,
As you are using htmleditor extender. So check this link
http://forums.asp.net/t/1789784.aspx/1[
^]
Also what you want to save in db is still not clear.
As if you save only string text in db removing html tags, then it will cause problem later on, if you want to display the saved text in the htmleditorextender.
Still you want to
save only string text removing HTML tags.
Check this link -
http://stackoverflow.com/questions/785715/how-can-i-strip-html-tags-from-a-string-in-asp-net?lq=1[
^]
A better approach would be - Saving the html text as it is but by
HttpUtility.HtmlEncode()
so later it gets displayed in editor as it is with
HttpUtility.HtmlDecode()
And where you need only text no html tags, make a method which returns string text by passing html extender text, with use of regex like above link(save only string text removing HTML tags) and use that method.
public string HTMLToString(string htmlText)
{
string strText =string.Empty;
if(!string.IsNullOrEmpty(htmlText))
{
strText = System.Text.RegularExpressions.Regex.Replace(HttpUtility.HtmlDecode(htmlText), @"<[^>]*(>|$)",string.Empty);
strText = System.Text.RegularExpressions.Regex.Replace(strText , @"[\s\r\n]+",string.Empty);
}
return strText;
}