Reputation: 2242
I hope the editor can be encoded because I want to post the editor text to the controller,but I find that when I refresh the page(click F5),the editor encode the text again.My Model.Body
also contains html mark: For example, first Time enter the page is OK,and show "My Model Body Is Here",and I refresh the page it show the html mark like below,but I just want to encode only one time,I also use no cache but it do not work.Third time I refresh the page,it encode again,and show <table><tbody>...
Model:
//after search,my Model.Body is here
<table>
<tbody>
<tr><td align="center" style="font-weight:bold;">
<span style="background-color:#ccff33;">My Model Body Is Here</span>
</td></tr>
</tbody>
</table>
View:
@(Html.Kendo().Editor()
.Name("Body")
.Tools(tools => tools.Clear()
.Bold().Italic().Underline().Strikethrough()
.JustifyLeft().JustifyCenter().JustifyRight().JustifyFull()
.InsertUnorderedList().InsertOrderedList()
.Outdent().Indent()
.CreateLink().Unlink()
.InsertImage()
.SubScript()
.SuperScript()
.ViewHtml()
.FontName()
.FontSize()
.FontColor().BackColor()
)
.HtmlAttributes(new { style = "width:90%;height:500px" })
.Value(Model.Body))
Controller:
[OutputCache(Duration = 0)]
public ActionResult Index(int id=0)
{
return View(ModelRepository.GetModelById(id));
}
Upvotes: 0
Views: 937
Reputation: 726
This is caused by the default encoding of the editor, when the page is fetched from the browser bfcache. In order to resolve that, set Encoded(false) in the view, and indicate that the field will contain HTML in the model, by setting the [AllowHtml] attribute.On the other hand,you can just disabe the bfcache.
Upvotes: 1
Reputation: 4054
Try setting .Encode(false)
in your editor. When displaying the content then you might have to do @Html.Raw(Model.Content)
Upvotes: 1