2013-01-09 75 views
2

我正在嘗試重新加載由tinymce保存的數據。當我這樣做時,所有的html標籤都可以在控件內部看到。Tinymce - 使用html標記重新加載數據

如何將html加載回控件,與以前保存的相同(沒有 標記可見)?

這裏是我的初始化:

$('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 

和我的textarea:

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

謝謝您的時間。 比利

回答

2

使用MVC 2 -

分辨率這個問題對我來說是存儲我的數據使用解碼HttpUtility.HtmlDecode。

然後,當拉回來並分配給我的模型的顯示(字符串)屬性時,我使用HttpUtility.HtmlEncode編碼了字符串。

最後,在視圖頁面上,我再次使用HttpUtility.HtmlDecode解碼了相同的屬性以進行顯示。

希望這可以幫助有類似問題的其他人。

+0

+1很高興你找到了一個可行的解決方案,並將其發佈在這裏 – Thariama