Reputation: 41
I am using Mvc 5 razor,and have used ckeditor to save data in database but when i am retrieving data on the view it is coming with all the html tags pls helpme how to display it in normal text form on the view
<div class="panel panel-default">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseThree" id="Inclusions">
<div class="panel-heading">
<h4 class="panel-title"> INCLUSIONS </h4>
</div>
</a>
<div id="collapseThree" class="panel-collapse collapse">
<div class="panel-body">
@Html.Raw(Html.DisplayFor(Model => Model.Itinerarydetail.Inclusions));
</div>
</div>
</div>
Upvotes: 0
Views: 4586
Reputation:
Here in my view when you get data from database use @Html.Raw
<div class="form-group">
@Html.LabelFor(model => model.Description,htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-sm-8">
<textarea type="text" class="ckeditor" name="Description">@item.Description</textarea>
@Html.ValidationMessageFor(model => model.Description, "", new { @class = "text-danger" })
</div>
Upvotes: 1
Reputation: 218722
When you use the Html.DisplayFor
helper method, razor will encode the content before rendering. You should use Html.Raw()
helper method which will not encode your content and pass the value you want to render directly to that.
<div class="panel-body">
@Html.Raw(Model.Itinerarydetail.Inclusions)
</div>
Upvotes: 4