Click here to Skip to main content
15,896,153 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using CKEditor to enter details (The details contains html elements). after that the details will be bind into a grid. In this I want to show the details without html tags in tooltip.

C#
protected void grdStepMain_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        int i = 0;
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            foreach (TableCell cell in e.Row.Cells)
            {
                i++;
                string description = cell.Text;
                if (cell.Text.Length > 8 && (i == 2))
                    cell.Text = cell.Text.Substring(0, 8) + "....";
              string newdescription = Regex.Replace(description, @"<[^>]+>|&nbsp;", "").Trim();
              cell.ToolTip = newdescription;
            }

        }
    }


But its not working please help me. Example:

CSS
string str= " &lt;h1&gt;&lt;span style=&quot;font-family:courier new,courier,monospace&quot;&gt;&lt;strong&gt;457457&lt;/strong&gt; 544444444444457457457&lt;/span&gt;";

The result in tooltip should be 457457544444444444457457457




Please hep me

Regards
jithesh A
Posted
Comments
Thomas Daniels 1-Apr-15 7:44am    
Are the tags in the string actually made of HTML Entities, as in your example?
jithesh a 1-Apr-15 7:47am    
yes...I am using CKEditor to create the string

1 solution

In your comment, you said that the HTML tags are actually made up with HTML Entities. In that case, a regex that matches from < to > won't work; you need a regex that matches from &lt; to &gt;:
C#
string newdescription = Regex.Replace(description, @"&lt;.+?&gt;|&nbsp;", "").Trim();
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900