Editor show html tags after postback (use Encode(true) and decode by HttpUtility.HtmlDecode in server)

2 posts, 0 answers
  1. Appvl
    Appvl avatar
    1 posts
    Member since:
    Jul 2013

    Posted 30 Aug 2013 Link to this post

    I have a view, use editor:
    @using (Html.BeginForm("Index", "Home"))
        @Html.Kendo().EditorFor(m=> m.MyHtml).Encode(true)

        <input type="submit" value="Save" />

    and in controller:
    public ActionResult Index()
                var viewModel = new ViewModel { MyHtml = "test <strong>html</strong>" };
                return View(viewModel);

            public ActionResult Index(ViewModel model)
                model.MyHtml = Server.HtmlDecode(model.MyHtml);
                //model.MyHtml == "test <strong>html</strong>" at here
                return View(model);

    the view in Get request is correct. Without any editing, click Save and after Post request, the view is showed html tags.

    Does it is bug or not? How to show correct html after postback without Encode(fase) + [AllowHtml] in model?
  2. Dimo
    Dimo avatar
    8406 posts

    Posted 02 Sep 2013 Link to this post


    Please refer to the following forum thread, which discusses the same topic:


    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top