开发者

How to get Plain Text from HTML editor in ASP.NET AJAX Control Toolkit?

开发者 https://www.devze.com 2023-01-19 20:13 出处:网络
How to get Plain Text from HTML editor in ASP.NET AJAX Cont开发者_Python百科rol Toolkit? Editor1.Content gives HTML text like

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

0

精彩评论

暂无评论...
验证码 换一张
取 消