regex - How to remove HTML tags from string using asp.net (Bold,strong,font names etc etc) -


i using ckeditor enter details (the details contains html elements ). after details bind grid. in want show details without html tags in tooltip.

protected void grdstepmain_rowdatabound(object sender, gridviewroweventargs e)     {         int = 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 = regex.replace(newdescription, @"<[^>]+>|&nbsp;", "").trim();             }          }     } 

but not working please me. example:

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;";  result in tooltip should 457457544444444444457457457 

please help. regards jithesh

 int = 0;             string newdescription = "";             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))                     {                         string = regex.replace(description, @"&lt;.+?&gt;|&nbsp;", "").trim();                         cell.text = a.substring(0, 8) + "....";                     }                     if (i == 2)                     {                         newdescription = regex.replace(description, @"&lt;.+?&gt;|&nbsp;", "").trim();                     }                     cell.tooltip = regex.replace(newdescription, @"&lt;.+?&gt;|&nbsp;", "").trim();                 }             } 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -