weixin_33713350 2017-10-24 08:26 采纳率: 0%
浏览 32

Kendo HTML编辑器

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:

enter image description here

But I see it like this:

enter image description here

  • 写回答

1条回答 默认 最新

  • weixin_33701617 2017-10-24 12:04
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分