Problem with a updatePanel

Oct 12, 2009 at 2:07 PM

Hi,

I'll want refresh my content in CKEditor when i select a different item in DropDownList but the result is the empty textarea instead of CKEditor when i use a UpdatePanel AJAX.

My masterPage has a ScriptManager.
My page has a UserControl ucCKEditor and she use a UpdatePanel for all controls.
My UserControl ucCKEditor has a <syx:CkEditor runat="server" ID="ckeditor" Width="950px" />.

When i use a UpdatePanel on my page, the ckeditor is bad.
When i not use UpdatePanel on my page, the ckeditor is good.
When i use a UpdatePanel on my page with a old Version (FCKEditor), the fckeditor is good.

Do you have a idea ?
I think that it's a problem with the name(ClientID) of my control CKEditor but...

Thanks and sorry for my bad english.

Oct 12, 2009 at 5:08 PM

Hi, i am having the same problem.  I changed the PreRender and the Render methods to:

protected override void OnPreRender(EventArgs e)
{
    base.OnPreRender(e);
    ScriptManager.RegisterClientScriptInclude(this, typeof(CkEditor), "CKEditorMain", this.Page.ResolveUrl(CkEditorJS));
    ScriptManager.RegisterStartupScript(this, typeof(CkEditor), "CKEditorRegister", string.Format("var t=\"{2}\"; var e = CKEDITOR.instances.{0}; if (e != null) CKEDITOR.remove(e); CKEDITOR.replace('{0}'{1}).setData(t);", ClientID, BuildConfigOptions(), GetTextForRender()), true);
}

protected override void Render(HtmlTextWriter writer)
{
    writer.Write("<textarea id=\"{0}\" name=\"{1}\"></textarea>", ClientID, UniqueID);
}

This works perfectly in firefox.  However in ie it works fine when you first access it but the second time you get the error:

Message: 'lang.about.title' is null or not an object
Line: 34
Char: 425
Code: 0
URI: http://localhost/CKEditor/ckeditor.js

I've played around with registering the second part of javascript within the init and pageLoad events but neither seem to help.  I'll post back if i get a solution, if anyone else could help that would be great.  Thanks

Nov 2, 2009 at 8:30 PM

Has anyone found a solution for this?  I am having the exact same problem.

Thanks,

Brian

Nov 9, 2009 at 5:51 PM

I am receiving the same error, but I receive it on the initial load of the page.  It may have something to do with the fact that I have the control on a page that uses a MasterPage.  My guess is that the client ID of the textbox is referenced incorrectly in the javascript for CKEditor, because it is not taking into account that ASP.NET modifies the client ID based on the containers (including the panel/div for the UpdatePanel and the ContentArea for the MasterPage).

Any solutions or suggestions would be appreciated.

 

Jan 14, 2010 at 4:15 PM
Edited Jan 14, 2010 at 4:46 PM

Hi, i think i've got this working but my solution is abit of a hack:

Edit CkEditor.cs file:

protected override void OnPreRender(EventArgs e)
{
    base.OnPreRender(e);
    ScriptManager.RegisterClientScriptInclude(this, typeof(CkEditor), "CKEditorMain", this.Page.ResolveUrl(CkEditorJS) + "?R=" + DateTime.Now.Ticks.ToString()); // Note a random string is appended to avoid caching issues in IE on the file, this is not the best solution (for both performance and bandwidth) but currently i am out of other ideas
    ScriptManager.RegisterStartupScript(this, typeof(CkEditor), "CKEditorRegister_" + ClientID, string.Format("var e = CKEDITOR.instances.{0}; if (e != null) CKEDITOR.remove(e); CKEDITOR.replace('{0}'{1}).setData('{2}');", ClientID, BuildConfigOptions(), GetTextForRender()), true);
    ScriptManager.RegisterOnSubmitStatement(this, typeof(CkEditor), "CKEditorAjaxOnSubmit_" + ClientID, string.Format("var e = CKEDITOR.instances.{0}; if (e != null) e.updateElement();", ClientID));
}

protected override void Render(HtmlTextWriter writer)
{
    writer.Write("<textarea id=\"{0}\" name=\"{1}\"></textarea>", ClientID, UniqueID);
}
 
Add to the bottom of the ckeditor.js file:
 
if(typeof(Sys) != 'undefined' && typeof(Sys.Application) != 'undefined')Sys.Application.notifyScriptLoaded();
 
Hope this helps.
Feb 22, 2010 at 3:56 PM

Hi jgd12345 Im trying to follow what you have done I got Scriptmanager working by using System.Web.Extensions but i cannot get  either:

  • BuildConfigOptions()
  •  GetTextForRender()

To work, I imagine it must be down to the references added to the project, With this modification are you applying it to the project and then building your own custom dll? if so anychance of posting your imports used.

 

BR Llloydz1

Ps Thanks for you efforts

Mar 4, 2010 at 9:28 AM

Hi Lloyd.  The BuildConfigOptions and GetTextForRender are methods that are within the server control.  Please note that you override the OnPreRender and Render methods of the server control and not the web page you wish to display your editor.  This is will also mean that you will only have to do it in one place whenever you use the control.

Hope this helps.

Mar 4, 2010 at 11:07 AM

Hi jgd12345 Thanks for your reply i finally figured it out just the other day but when i built the dll and used it with my application the ckeditor doesn't even render at all.

I have done as suggested to ckeditor..js file, im not sure what i have done wrong.

 

My Problem that i had originally is that i have createded a web app that updates 3 websites and these website each have tabcontainer with 3 different descriptions in them for each product, so in my app i have to pull in  a template for each tab on each website and then produce the correct html from that. So I'm actually loading 18 Ckeditor's on one page :-(. They all work when i populate them with text, but as soon as i do a post back all the ones in the first tab panel work and the rest of them wont allow me to click on them and expand the toolbar,and they do not show the html content and appear blank.

My settings used for the ckeditor as follows:

<syx:CkEditor  ID="EdWzTtl1" runat="server" Width="490px" height="400px" CanCollapseToolbar="True"
DialogCoverBackground="Transparent" EnableMoreColors="True" ForcePasteAsPlainText="False" LanguageDirection="ltr" MaxHeight="-1"
MaxWidth="-1" MinHeight="-1" MinWidth="-1" PasteFromWordKeepsStructure="False" PasteFromWordRemoveStyle="False" PastFromWordIgnoreFontFace="False"
PopupZIndex="-1" Resizable="True" RemovePlugins="true" ToolbarStartExpanded="False"/>

 

I'm hoping that maybe it is a reference error in the JS problem,  any chance you could upload your version for me would be great so i can at least test. or if there is any setting which anyone can see that is wrong please let me know

Many many thanks Lloydz1

Mar 30, 2010 at 4:24 PM

Hi Lloyd.  Sorry about the late reply but i'm not receiving email updates when someone responds to my posts or they are being filtered into my junk.  Anyway my control is very much like the default i have added one further change since which might help.  I changed:

return Text.Replace("\"", "\\\"").Replace("\r\n", "\\r\\n").Replace("\n", "\\n");

to:

return Text.Replace("\"", "\\\"").Replace("\r\n", "\\r\\n").Replace("\n", "\\n").Replace("/", "\\/");

I had some issues with script tags not rendering correctly within the editor.  Not sure if this will help but worth a try.  Sorry i can't help more.

Mar 31, 2010 at 9:35 AM

Hi, i don't understand where i can find  the function

  • BuildConfigOptions()
  • GetTextForRender()

 

thank you for your help.

Apr 5, 2010 at 3:56 PM

Thanks for all of the helpful information.  alex84, the method names should have camel casing.  I think that's what your problem is.

This all seemed to work well for me however I am receiving a JS error after the second postback.  I think those registerscriptblocks are getting registered mutliple times or something and causing a conflict.

The error occurs in both firefox and IE, but only the second time I post back.

Any thoughts?

Any help would be greatly appreciated.

May 4, 2010 at 10:56 PM

We are also experiencing an issue with the UpdatePanel, but it is a bit more complicated than just updating the editor on a partial postback.  We remove and then readd the editor at a later partial postback.

 

Here is the other thread: http://syrinxckeditor.codeplex.com/Thread/View.aspx?ThreadId=211577

 

Jul 28, 2010 at 4:26 PM

Hi jqd123456,

I made all the changes you said and everything looks good, no mather how many postbacks I had, the control is rendering ok.

What I have to do now is hidde the control on the postback of a selected index change of a dropdownlist. Since the control has a property Visible, I used it. However I'm getting js error at a later partial postback, I think pretty similar to the problem that Xitch13 is having.

So Xitch13 or jqd123456, if have a solution for this could you please post it here?

I also tried hidding the cotrol within js, setting visibility to hidden but that doesn't work.

Thank you very much!

Sep 4, 2010 at 6:55 AM

jgd12345. you are the ONE!!!