Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Encode String To Html Asp.Net MVC [duplicate]

Tags:

asp.net-mvc

Possible Duplicate:
ASP.NET MVC Razor render without encoding

One of the proerties of my Product object is returning a string that has html in it. When I set the model to the view, the view reads it as text and not html. How do I let the view know to read the property as html?

<td colspan="2">
 <div>
   <label >                             
       @Model.LongDescription  
   </label>                                 
 </div>
</td>
like image 310
Nick LaMarca Avatar asked Jul 30 '26 19:07

Nick LaMarca


1 Answers

Razor encodes everything by default, you just have to use @Html.Raw see this question which is pretty much the same problem you have

<td colspan="2">
 <div>
   <label >                             
       Html.Raw(@Model.LongDescription)
   </label>                                 
 </div>
</td>
like image 184
jorgehmv Avatar answered Aug 02 '26 12:08

jorgehmv



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!