문제

We are using mvc 2.0 We are getting the body from db where its stored in this format

 (strore in db as varchar) 
"<p>Thank you for submitting your feedback about recent experience</p>  
<p>Regards,</p>  
<p>The XYZ team</p>"

 (This is what I am trying on View)
 <div>
            <%= Html.TextAreaFor(dataModel => dataModel.body, new { @class ="row-class", @rows = 20 })%>
</div>

Currently the content is displayed with HTML tags in the TextArea, which I dont want. I just want to display the formated text as per the html. I have tried couple of things like @Html.Raw but in vein. If anyone has gone through this kind of issue please let me know or any article which can lead me in right direction will also help..

Thanks for your time..

도움이 되었습니까?

해결책

Have you tried simply <%= Model.Body %>

다른 팁

To display that as html, try @Html.Raw(Model.body) (or Model.body, whatever is name of your property).

To edit html, you need a html editor. I used TinyMce for that, and I was happy with it.

There is even a nuget package with it.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top