2
votes

I am trying to reload data saved by tinymce. When i do so all of the html tags are then viewable inside the control.

How do you load html back into the control the same as it was previously saved(without the tags viewable)?

Here is my initialization:

    $('textarea.tinymce').tinymce({
        // Location of TinyMCE script
        script_url : '/Scripts/tinymce/tiny_mce.js',

        encoding: "xml",

        // General options
        theme : "advanced",
        plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

        // Theme options
        theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect,|,forecolor,backcolor",
        theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,undo,redo,|,image,",
        theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,ltr,rtl,|,fullscreen",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : false,

        // Example content CSS (should be your site CSS)
        //content_css : "/Content/content.css",

        // Drop lists for link/image/media/template dialogs
        template_external_list_url: "/Scripts/tinymce/lists/template_list.js",
        external_link_list_url: "/Scripts/tinymce/lists/link_list.js",
        external_image_list_url: "/Scripts/tinymce/lists/image_list.js",
        media_external_list_url: "/Scripts/tinymce/lists/media_list.js"
    });//end tinymce

and my textarea:

<%: Html.TextArea("Blog", Model.Blog, new { @class = "tinymce", rows = "25", cols = "40"  })%>

Thank you for your time. Billy

2

2 Answers

2
votes

Using MVC 2 -

The resolution to this issue for me was to store my data decoded using HttpUtility.HtmlDecode.

Then when pulling it back up and assigning to a display(string) property of my model i encoded the string using HttpUtility.HtmlEncode.

Finally on the view page i decoded that same property for display using HttpUtility.HtmlDecode once more.

Hope this helps someone else with a similar issue.

0
votes

See http://www.tinymce.com/wiki.php/Configuration:encoding

Seems like you need to set encoding: 'xml' on your configuration.