本文介绍了Tinymce Editor在保存并重新加载updatepanel内的数据后显示html标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 当第一次加载时,数据显示完美,但在我更改了一些样式并保存数据后。再显示数据然后显示html标签,即< strong> A< strong> 我完整的tinymce编辑器代码 函数initTextArea(){ tinyMCE.init({ 模式:确切, 主题:高级, forced_root_block:false,//启动tinyMCE没有任何段落标签 编码:xml, 元素:'<%= txtEmail.ClientID%>', editor_selector :tinyMCE, //插件:拼写检查,自动链接,列表,分页,样式,图层,表格,保存,advhr,advimage,advlink,情感, iespell,inlinepopups,insertdatetime,预览,媒体,searchreplace,打印,文本菜单,粘贴,方向性,全屏,不可编辑,visualchars,不间断, xhtmlxtras,template,wordcount,advlist,autosave, 插件:粘贴, paste_text_sticky:true, setup:function(ed){ ed.onInit.add(function(ed){ ed.pasteAsPlainText = true; }); }, theme_advanced_buttons1:剪切,复制,粘贴,|,撤消,重做,|,粗体,斜体,下划线,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,outdent,indent, theme_advanced_buttons2:forecolor,backcolor,fontselect ,fontsizeselect,|,搜索,替换, theme_advanced_buttons3:, theme_advanced_toolbar_location:top, theme_advanced_toolbar_align:left , theme_advanced_statusbar_location:无, spellchecker_languages:English = en, //示例内容CSS(应该是你的网站CSS) content_css:../ ../../Farvision.Common/script/tiny_mce/themes/advanced/skins/default/content.css, //删除链接列表/图像/媒体/模板对话框 template_external_list_url:lists / template_list.js, external_link_list_url:lists / link_list.js, external_image_list_url:lists / image_list.js, media_external_list_url:lists / media_list.js, //样式格式 style_formats:[ {title:'Bold text',inline:'b'}, {title:'Red text',inline: 'span',styles:{color:'#ff0000'}}, {title:'Red header',block:'h1',styles:{color:'#ff0000'}}, {title:'Example 1',inline:'span',classes: 'example1'}, {标题:'示例2',内联:'span',类:'example2'}, {标题:'表样式'} , {标题:'表格行1',选择器:'tr',类:'tablerow1'} ], //替换模板插件的值 template_replace_values:{ 用户名:有些用户, staffid: 991234 } }); } initTextArea( ); 函数fnExit(){ var redirectURL ='<%= Convert.To String(Session [PageToRedirect])%>'; if(redirectURL == undefined || redirectURL =='') redirectURL ='../../Farvision.Common/Common/Forms/R2_frmHome.aspx'; location.href = redirectURL; 返回false; } var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_initializeRequest(InitializeRequest); prm.add_endRequest(EndRequest); var postBackElement; 函数InitializeRequest (发件人,args){ if(prm.get_isInAsyncPostBack()) args.set_cancel(true); postBackElement = args.get_postBackElement (); tinyMCE.execCommand('mceRemoveControl',false,'<%= txtEmail.ClientID%>'); } 函数EndRequest(sender,args){ initTextArea(); tinyMCE.idCounter = 0; //用textarea的id替换textareaId tinyMCE.execCommand('mceFocus',false,'<%= txtEmail。 ClientID%>'); tinyMCE.execCommand('mceAddControl',false,'<%= txtEmail.ClientID%>'); } 函数UpdateTextArea(){ tinyMCE.triggerSave(false,true); } var tdEmailID =''; 函数SetEmailDiv(){ tdEmailID.find( [id * ='hdnEmailCon'])。val(escape(tinyMCE.activeEditor.getContent())); var radCmbBox = $ find('<%= cmbEmailType.ClientID%> ;'); tdEmailID.find([id * ='hdnEmailType'])。val(radCmbBox.get_text()); document.getElementById( divEmailContent)。style.display =none; } function openEmailDiv(){ var pdiv = document.getElementById(divEmailContent); pdiv.style.display =inline; pdiv.style.top =(parseInt(document.body.clientHeight) - parseInt(pdiv.style.height))/ 2 +'px'; pdiv.style.left =( parseInt(document.body.clientWidth) - parseInt(pdiv.style.width))/ 2 +'px'; 返回false; } 函数OnEmailEdit(){ var tr = $(this).closest(tr); tdEmailID = tr ; tinyMCE.activeEditor.setContent(unescape(tr.find([id * ='hdnEmailCon'])。val())); var radComboBox = $ find('<%= cmbEmailType.ClientID%>'); var item = radComboBox.findItemByText(tr.find([id * ='hdnEmailType'])。val( )); item.select(); 返回openEmailDiv(); } 这里我觉得escape和unescape函数不能正常工作When First time load the data is display in perfect,but after i have changed some style and save data.Again i show data then display html tags i.e, <strong>A<strong>My full tinymce editor code function initTextArea() { tinyMCE.init({ mode: "exact", theme: "advanced", forced_root_block: false, // Start tinyMCE without any paragraph tag encoding: "xml", elements: '<%=txtEmail.ClientID %>', editor_selector: "tinyMCE", // plugins: "spellchecker,autolink,lists,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,wordcount,advlist,autosave", plugins: "paste", paste_text_sticky: true, setup: function(ed) { ed.onInit.add(function(ed) { ed.pasteAsPlainText = true; }); }, theme_advanced_buttons1: "cut,copy,paste,|,undo,redo,|,bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,outdent,indent", theme_advanced_buttons2: "forecolor,backcolor,fontselect,fontsizeselect,|,search,replace", theme_advanced_buttons3: "", theme_advanced_toolbar_location: "top", theme_advanced_toolbar_align: "left", theme_advanced_statusbar_location: "none", spellchecker_languages: "English=en", // Example content CSS (should be your site CSS) content_css: "../../../Farvision.Common/script/tiny_mce/themes/advanced/skins/default/content.css", // Drop lists for link/image/media/template dialogs template_external_list_url: "lists/template_list.js", external_link_list_url: "lists/link_list.js", external_image_list_url: "lists/image_list.js", media_external_list_url: "lists/media_list.js", // Style formats style_formats: [ { title: 'Bold text', inline: 'b' }, { title: 'Red text', inline: 'span', styles: { color: '#ff0000'} }, { title: 'Red header', block: 'h1', styles: { color: '#ff0000'} }, { title: 'Example 1', inline: 'span', classes: 'example1' }, { title: 'Example 2', inline: 'span', classes: 'example2' }, { title: 'Table styles' }, { title: 'Table row 1', selector: 'tr', classes: 'tablerow1' } ], // Replace values for the template plugin template_replace_values: { username: "Some User", staffid: "991234" } }); } initTextArea(); function fnExit() { var redirectURL = '<%= Convert.ToString(Session["PageToRedirect"]) %>'; if (redirectURL == undefined || redirectURL == '') redirectURL = '../../Farvision.Common/Common/Forms/R2_frmHome.aspx'; location.href = redirectURL; return false; } var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_initializeRequest(InitializeRequest); prm.add_endRequest(EndRequest); var postBackElement; function InitializeRequest(sender, args) { if (prm.get_isInAsyncPostBack()) args.set_cancel(true); postBackElement = args.get_postBackElement(); tinyMCE.execCommand('mceRemoveControl', false, '<%=txtEmail.ClientID %>'); } function EndRequest(sender, args) { initTextArea(); tinyMCE.idCounter = 0; // replace textareaId by the id of your textarea tinyMCE.execCommand('mceFocus', false, '<%=txtEmail.ClientID %>'); tinyMCE.execCommand('mceAddControl', false, '<%=txtEmail.ClientID %>'); } function UpdateTextArea() { tinyMCE.triggerSave(false, true); } var tdEmailID = ''; function SetEmailDiv() { tdEmailID.find("[id*='hdnEmailCon']").val(escape(tinyMCE.activeEditor.getContent())); var radCmbBox = $find('<%=cmbEmailType.ClientID %>'); tdEmailID.find("[id*='hdnEmailType']").val(radCmbBox.get_text()); document.getElementById("divEmailContent").style.display = "none"; } function openEmailDiv() { var pdiv = document.getElementById("divEmailContent"); pdiv.style.display = "inline"; pdiv.style.top = (parseInt(document.body.clientHeight) - parseInt(pdiv.style.height)) / 2 + 'px'; pdiv.style.left = (parseInt(document.body.clientWidth) - parseInt(pdiv.style.width)) / 2 + 'px'; return false; } function OnEmailEdit() { var tr = $(this).closest("tr"); tdEmailID = tr; tinyMCE.activeEditor.setContent(unescape(tr.find("[id*='hdnEmailCon']").val())); var radComboBox = $find('<%=cmbEmailType.ClientID %>'); var item = radComboBox.findItemByText(tr.find("[id*='hdnEmailType']").val()); item.select(); return openEmailDiv(); }here i think escape and unescape function is not working properly推荐答案 这篇关于Tinymce Editor在保存并重新加载updatepanel内的数据后显示html标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-30 22:20