0

I want to remove the html that is stored in my database for Comments field. Right now I'm able to shorten it less than 16 characters but when it is display on a datatable calling the ShortComments field but the HTML still shows.

      <div>Test<spa ...

I have it set up as this in my model class file:

 public string Comments { get; set; }

 public string ShortComments => Comments?.Length > 14 ? $" 
  {Description.Substring(0, 13)} ..." : Comments;

How do I fix the above html to strip out the html so it says "Test..." on the view page.

Tried this

      <td>@Regex.Replace(dorItem.ShortDescription, @"<[^>]+>|&nbsp;", 
      "").Trim()</td>

and it does remove most of html except

      <span style> 

How can I get rid of that?

2
  • I think that will meet your need. stackoverflow.com/questions/4878452/remove-html-tags-in-string Commented Oct 18, 2019 at 19:11
  • Tried this and it does remove most of html except <span style>. How can I get rid of that? <td>@Regex.Replace(dorItem.ShortDescription, @"<[^>]+>|&nbsp;", "").Trim()</td> Commented Oct 24, 2019 at 20:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.