I am using summernote to add Image, Video, text. Also, I save image or video as Html Code that is type string to database. When I retreive video or image from the database
Html.Raw
method returns System.Web.IHtmlString
, I think what you need is just passing string
property containing HTML tags (AFAIK Html.Raw
helper can't be used inside other HTML helpers like DisplayFor
or TextBoxFor
).
It is possible to use HttpUtility.HtmlDecode
for Content
property before TextAreaFor
as shown by this example (especially if HTML tags are unknowingly encoded):
@model Article
@{
Model.Content = HttpUtility.HtmlDecode(Model.Content);
}
@Html.TextAreaFor(x => x.Content, new { @class = "", placeholder = @Blog.Helper.Resources.Content, @id = "summernote_1" })
By using this way, you can render HTML tags properly from viewmodel's string property without losing model binding.
.textarea {
padding: 2px;
width: 250px;
height: 200px;
border: solid 1px #e0e0eb;
overflow: scroll;
overflow-y: scroll;
overflow-x: hidden;
}
write your html content using @Html.Raw() inside a div that contains a class "textarea".
<div class="textarea"> @Html.Raw(Model.NOTE) </div>