0

Here is my code:

<asp:UpdatePanel ID="up1" runat="server">
    <ContentTemplate>
        <script type="text/javascript">
            var app = Sys.WebForms.PageRequestManager.getInstance();
            app.add_pageLoaded(createEditor)
            app.add_initializeRequest(removeEditor)

            function createEditor() {
                if (editor) return;
                var config = { toolbar: 'Description', width: 540 };
                editor = CKEDITOR.replace("editor", config);
            }

            function removeEditor() {
                if (!editor) return;
                editor.destroy();
                editor = null;
            }
        </script>

        <textarea id="editor" cols="1" rows="1" runat="server">
        </textarea>

        <asp:Button ID="btnsubmit" Text="Get 'er Done" runat="server" />
        <div>
            <%=strmessage%>
        </div> 
    </ContentTemplate>
</asp:UpdatePanel>

When the panel loads, the CKEditor is applied to the textarea. When the panel posts back, the editor must be destroyed to put the data back into the textarea. In this code, the Editor is not destroyed in time to update the postback data. It works if I do this:

<asp:Button ID="btnsubmit" onClientClick="removeEditor()" Text="Get 'er Done"
   runat="server" />

The problem is the UpdatePanel is not always triggered with that button, sometimes it's triggered remotely. It seems that by the time initializeRequest is called, the value for the textarea is already set. Is there a way to update that value at this point?

4

1 回答 1

0

答案是:如果您使用的是 .NET,请忘记 CKEditor、tinyMCE 和所有其他富文本编辑器。我不敢相信我花了这么长时间才发现AJAX Control Toolkit

于 2012-10-12T18:46:51.043 回答