Reputation: 89
I have a kendo html editor. And in the body I have a default text. So if you load the html kendoeditor then the default text will be shown.
It looks like this:
public class EmailTemplateController : BaseController
{
// GET: Salaris/EmailTemplate
[HttpGet]
public ActionResult Index(EmailTemplate model)
{
model.EmailContent = "Nieuwe inhoud...";
return Json(model, JsonRequestBehavior.AllowGet);
// return View();
}
}
and I have the view like this:
@model SDB.Models.EmailTemplate.EmailTemplate
<div id="emailContent">
<div class="property full">
@Html.EditorFor(m => m.EmailContent, "HtmlEditorEmailTemplate")
@Html.ValidationMessageFor(m => m.EmailContent)
</div>
</div>
<script>
$(document).ready(function () {
$.ajax({
url: "/EmailTemplate/Index",
type: "post",
datatype: "json",
data: placeMarker,
success: function (response) {
if (response.Success) {
}
else {
//do something
}
},
error: function (xhr, status) {
//do something
}
});
});
</script>
And this is the model:
public class EmailTemplate
{
public string EmailContent { get; set; }
}
The problem is that if I run the view. I see the message: Nieuwe inhoud...
But I only see the text. So the kendo htmleditor is not shown anymore.
This is how it has to be:
But I see it like this:
Upvotes: 0
Views: 288
Reputation: 61839
Simply replace
return Json(model, JsonRequestBehavior.AllowGet);
with
return View(model);
There's no need to use JSON at all here, it won't work to populate a Razor template. Instead you must return a view (or partial view) for that to work.
You can also remove your $.ajax code, because it doesn't do anything useful.
Upvotes: 1