简体   繁体   中英

How to render HTML tags in Html.EditorFor in mvc 4 razor

I have one property named Description in my class. I am having value in it some thing like this

Object.Description = "<b>Hello</b>";

Now I am showing this in view page using Html.EditorFor

@Html.EditorFor(x => x.Object.Description);

This is showing text as "<b>Hello</b>" instead of showing "Hello" in bold. ie it is not rendering HTML tags.

I know that I can render HTML tags like this

@Html.Raw(HttpUtility.HtmlDecode(Object.Description));

But how to use it with EditorFor HTML helper so that I can show all rendered content in textarea ?

Note: I am using http://jqueryte.com/ for showing editor for textarea.

Textareas do not render HTML or accept any content styling. They encode all HTML characters. You'd need to use a plugin to make your textarea APPEAR to bold text via CSS trickery.

在我的情况下 html.editorfor 并在其他页面上显示内容:

@Html.Raw(HttpUtility.HtmlDecode(abouts[0].Description))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM