我在更新面板中使用了TinyMCE,但它在每次部分回發後都會消失,爲什麼?它應該在任何情況下都能正常工作,即使官方網站也沒有關於它的說法。爲什麼我的控件在回發中消失?
我已經用它是這樣的:
<script type="text/javascript">
tinymce.init({
selector: '#<%=txtBoxBody.ClientID%>',
height: 200,
theme: 'modern',
plugins: [
'advlist autolink lists pagebreak',
//'searchreplace wordcount visualblocks visualchars fullscreen',
'insertdatetime save contextmenu directionality',
' paste textcolor textpattern print'
],
toolbar1: 'insertfile undo redo | fontsizeselect | forecolor emoticons | fontselect emoticons | styleselect | bold italic | alignleft aligncenter alignright alignjustify',
//toolbar2: 'print preview media | forecolor backcolor emoticons',
//image_advtab: true,
fontsize_formats: '8pt 9pt 10pt 11pt 12pt 14pt 18pt 20pt 22pt 24pt 26pt 28pt 36pt 48pt 72pt',
//templates: [
// { title: 'Test template 1', content: 'Test 1' },
// { title: 'Test template 2', content: 'Test 2' }
//],
content_css: [
'//fast.fonts.net/cssapi/e6dc9b99-64fe-4292-ad98-6974f93cd2a2.css',
'//www.tinymce.com/css/codepen.min.css'
]
});
</script>
on this txtbox
<asp:TextBox runat="server" ID="txtBoxBody" Rows="20" Columns="25" TextMode="MultiLine" CssClass="form-control"></asp:TextBox>
它出現在第一頁加載,但後門柱沒有回來 UPDATE:
它試圖這樣在頁面加載事件
//ScriptManager.RegisterStartupScript(this, this.GetType(), txtBoxBody.UniqueID + "Add", "tinyMCE.execCommand('mceAddEditor', true,'" + txtBoxBody.ClientID + "');", true);
//ScriptManager.RegisterOnSubmitStatement(this, this.GetType(), txtBoxBody.UniqueID + "Remove", "tinyMCE.execCommand('mceRemoveEditor', true,'" + txtBoxBody.ClientID + "');");
它使其可見,但使形式充滿麻煩,即全面回發和不同的問題。
更新:我已經使用JavaScript的pageLoad並把這個代碼裏面,但然後插件消失。
更新:那麼我想什麼的Piyush建議
<script type="text/javascript">
function SetEditor() {
tinymce.init({
selector: '#<%=txtBoxBody.ClientID%>',
height: 200,
theme: 'modern',
plugins: [
'advlist autolink lists pagebreak',
//'searchreplace wordcount visualblocks visualchars fullscreen',
'insertdatetime save contextmenu directionality',
' paste textcolor textpattern print'
],
toolbar1: 'insertfile undo redo | fontsizeselect | forecolor emoticons | fontselect emoticons | styleselect | bold italic | alignleft aligncenter alignright alignjustify',
//toolbar2: 'print preview media | forecolor backcolor emoticons',
//image_advtab: true,
fontsize_formats: '8pt 9pt 10pt 11pt 12pt 14pt 18pt 20pt 22pt 24pt 26pt 28pt 36pt 48pt 72pt',
//templates: [
// { title: 'Test template 1', content: 'Test 1' },
// { title: 'Test template 2', content: 'Test 2' }
//],
content_css: [
'//fast.fonts.net/cssapi/e6dc9b99-64fe-4292-ad98-6974f93cd2a2.css',
'//www.tinymce.com/css/codepen.min.css'
]
});
}
</script>
<script type="text/javascript">
// below will execute first time when page load
SetEditor();
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args) {
// this will execute on partial postback
SetEditor();
}
</script>
但同樣的問題
不工作sir – Stacky
那麼,我試着用同樣的方式,它爲我工作。你把所有這些東西放在.aspx文件中了嗎? –
是的,先生,我做了,它不起作用 – Stacky