How to get Plain Text from HTML editor in ASP.NET AJAX Control Toolkit?
How to get Plain Text from HTML editor in ASP.NET AJAX Cont开发者_Python百科rol Toolkit?
Editor1.Content
gives HTML text like
This is <span style=\"font-weight: bold\">BOLD</span> text
while i want plain text only
This is BOLD text
Just write this method in your code:
public static string GetTextonly(string editorcontent)
{
string strtext = "";
strtext = Regex.Replace(editorcontent, @"<(.|\n)*?>", string.Empty);
return strtext;
}
after write this outside:
string plaintext = GetTextonly(txtMessage.Content);
you just add namespace for System.Text.RegularExpression
精彩评论