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);
            }

            [HttpPost]
            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
    Admin
    Dimo avatar
    8333 posts

    Posted 02 Sep 2013 Link to this post

    Hello,

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

    http://www.kendoui.com/forums/kendo-ui-web/editor/problems-with-editor-showing-html-tags.aspx

    Regards,
    Dimo
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top