tinyMce activeeditor 在回发时为空

Vee*_*eer 3 c# asp.net tinymce

我正在使用tinymce editor具有确切 ID 的文本区域。它在页面加载上运行良好。但是,当我单击 asp 按钮“保存”时,回发以将数据保存在数据库中,活动编辑器变为空并且不保留其值。如何克服这个问题?

我在页面加载中的 tinyMce 初始化代码是

tinyMCE.init({
mode: "exact",
elements : "divLabTemplateTree",
encoding: "xml",
convert_urls: false,
theme: "advanced",
width:"300",
height:"400",
skin : "o2k7",
plugins: "spellchecker,pagebreak,style,layer,table,advhr,advimage,advlink,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,paste,directionality,fullscreen,visualchars,nonbreaking,xhtmlxtras",
extended_valid_elements: "iframe[src|width|height|name|align]",
theme_advanced_buttons1: "spellchecker,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect,|,print,fullscreen",
theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,media,advhr,|",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_path_location: "bottom",
theme_advanced_resizing: true,
theme_advanced_resize_horizontal: false,    
dom_loaded : 1,
theme_advanced_styles: "Link to Image: lightbox;Image Right Border: rightbordered;Image Left Border: leftbordered;Darker Text: darker",
setup: function (ed) {
    ed.onSaveContent.add(function (i, o) {
        o.content = o.content.replace(/&#39/g, "&apos");
    });

    ed.onInit.add(function(ed) {
        tinyMCE.execCommand("mceAddControl", true, "divLabTemplateTree");
    });

    }
});
Run Code Online (Sandbox Code Playgroud)

我正在设置它的值

if(tinyMCE.activeEditor != null)
{
    tinyMCE.activeEditor.setContent("bbbbbbbbbbbbbbb");
}
Run Code Online (Sandbox Code Playgroud)

Tha*_*ama 5

当页面初始化时 tinyMCE.activeEditor 为 null,直到用户明确单击进入编辑器。

推荐使用tinymce.get('your_editor_id')这里。您的编辑器等于编辑器初始化的 textarea id。如果此 textarea(或其他 html 源文件)没有 id,则content用作默认值。