Classic editor showing HTML tags

2 posts, 0 answers
  1. Mike
    Mike avatar
    12 posts
    Member since:
    Feb 2015

    Posted 26 Apr 2015 Link to this post

    This is the value that's in the database and being passed to the view:

    <p>this is a paragraph</p>

     This is what is showing in the Editor:

     <p>this is a paragraph</p>

    I've searched online for the solution, and found that I need to set encoded = false in the editor, and [AllowHtml] attribute to field in the class. I did that, but am still having the issue. 

    Here is the code in the view for the editor -- the first line appends a text area into a div:

     

            $("#divParagraphs").append('<div class="search-box"><div class="row"><div class="col-md-12">Paragraph:</div></div><div class="row"><div class="col-md-12"><textarea class="Paragraph" id=' + id + '></textarea><input type="hidden" id=' + id + '_id value=' + pid + ' /></div></div></div>');

             $("#" + id).kendoEditor({
                encoded: false,
                tools: [
                    "bold",
                    "italic",
                    "underline",
                    "strikethrough",
                    "justifyLeft",
                    "justifyCenter",
                    "justifyRight",
                    "justifyFull",
                    "createLink",
                    "unlink",
                    "insertImage",
                    "createTable",
                    "addColumnLeft",
                    "addColumnRight",
                    "addRowAbove",
                    "addRowBelow",
                    "deleteRow",
                    "deleteColumn",
                    "foreColor",
                    "backColor"
                ]
            });

     I'm out of ideas :-) Please help.

     Thanks,

    Mike

     

  2. Dimo
    Admin
    Dimo avatar
    8330 posts

    Posted 28 Apr 2015 Link to this post

    Hi Mike,

    The Razor view engine encodes HTML strings automatically. Please make sure that the value, which is passed to the Editor, is not double encoded.

    http://www.telerik.com/forums/saving-as-html-viewing-as-html

    Also, keep in mind that a similar issue can occur during validation:

    http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/editor/overview#kendo-ui-editor-shows-html-tags-after-validation

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