Here's a simple sample:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ckTest.aspx.cs" Inherits="CLGHR.ckTest" %> <%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>CKEditor Validation Test</title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="SM1" runat="server" EnablePartialRendering="true"></asp:ScriptManager> <div> <asp:UpdatePanel runat="server" ID="UP1" UpdateMode="Conditional"> <ContentTemplate> <p> Title: <br /> <asp:TextBox ID="TB_Title" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RFV_Title" runat="server" ControlToValidate="TB_Title" ErrorMessage="Title is required" ValidationGroup="content">*</asp:RequiredFieldValidator> </p> <p> <CKEditor:CKEditorControl ID="TB_Content" runat="server"></CKEditor:CKEditorControl> </p> <p> <asp:Button ID="Btn_Submit" runat="server" ValidationGroup="content" Text="Submit" onclick="Btn_Submit_Click" /> </p> </ContentTemplate> </asp:UpdatePanel> </div> </form> </body> </html>
When any ajax postback occurs the editor disappears.
Is this a known problem and are there any workarounds?
Re: asp.net Editor disappears on ajax postback
Hello
Following the changes in ticket 8089 the problem of the disappearing editor is solved when there is a validation error.
Unfortunately as soon as the validation is ok, the editor disappears again:
I've quite the same example as wmcainsh except that I've a DropDownList with AutoPostback set to true instead of the TextBox.
Selecting an item in the dropdownlist makes a postback and a partial rendering, the editor is still there: OK
Selecting the default item, clicking on the button to make a postback, client validation occurs, fails, the editor is still there : OK (thanks to the changes of the ticket)
After this, selecting an item in the dropdownlist, a postback occur (partial rendering), client validation succeeded, the editor disapears : KO
I hope it's clear enough and that you'll be able to solve this part of the problem too.
Keep it simple!
The update panel has a pageLoad() javascript function that gets called after a postback. You can use this event to replace the intance of the ckeditor. Assuming that the html for the editor uses a runat server like this
you can get the rendered tag name using the page source.
function pageLoad(){
CKEDITOR.replace("ctl00_ContentPlaceHolder1_myeditor_myeditor");
}