i noticed if the button is outside the update panel, then it works with no problems (hope that helps solving why it doesn't work when buttton is inside the updatepanel)
Guys I need you to make sample websites with the "common" cases of using the update panels with the CKEditor, So I can see where its working and where not, and hopefully fix it! Personally I don't use Update Panels, every most of my javascript I write myself, so I'm doing this for you. (Even a large part of Microsoft's controls do not support the MS Ajax!)
danielgindi wrote:Guys I need you to make sample websites with the "common" cases of using the update panels with the CKEditor, So I can see where its working and where not, and hopefully fix it! Personally I don't use Update Panels, every most of my javascript I write myself, so I'm doing this for you. (Even a large part of Microsoft's controls do not support the MS Ajax!)
try this scenario
you have 2 update panels and want to change the toolbar/styles in the editor
CKEditor's javascript generated an error that the "instance already exists". So we need to remove the instance before telling it again to replace the textbox with the CKEditor, after every postback.
So now when there's MS Ajax available, I add javascript to check to see if there's an instance already, and if so - remove using CKEditor.remove(instance).
The problem now, is that the CKEditor has the most basic toolbar after postback, so the cleanup obviously isn't full. I do not know if there's better API for that, or if that is a CKEditor bug? Maybe someone please report this to the development team...
Hi again, I can confirm too that it work, at least partly: A situation where it "fails" is where you have a dropdownlist set to autopostback and the ckEditor inside a updatepanel. When you then change the selected item in the dropdownlist and it make a postback which should set the value of the CKEditor, but the CKEditor remains empty!
Lets say in that dropdownlist we have to options: "Option 1" and "Option 2". If you select Option 1 it should make a postback a set the CKEditor.value = "Option 1", and ofcause if you select Option 2 it should still make a postback and set the CKEditor.Value = "Option 2".
Am I able to set the CKEditors value in another way, or can this be fixed or something?
Btw. Thanks so far, you have really done a great job
marci wrote:Hi again, I can confirm too that it work, at least partly: A situation where it "fails" is where you have a dropdownlist set to autopostback and the ckEditor inside a updatepanel. When you then change the selected item in the dropdownlist and it make a postback which should set the value of the CKEditor, but the CKEditor remains empty!
Lets say in that dropdownlist we have to options: "Option 1" and "Option 2". If you select Option 1 it should make a postback a set the CKEditor.value = "Option 1", and ofcause if you select Option 2 it should still make a postback and set the CKEditor.Value = "Option 2".
Am I able to set the CKEditors value in another way, or can this be fixed or something?
Btw. Thanks so far, you have really done a great job
About the build number, I have no idea, it is automatically generated when you specify * instead of specific build, and that is the case...
About the disappearing value - Still have no idea. Please attach a full example of your situation that I can test. CKEditor's inner engine AND API are entirely different than FCK. So the approach to making it .NET control must be different, and some problems are expected at this stage. So we have two problems left to solve - the disappearing value, and the minimized toolbar.
Anyone has any idea how to properly cleanup the CKEditor instance before replacing it again?
I have tried with your project, and it works just fine. Tried with Chrome, IE8 and IE7. Clicking either of the Option 1/Option 2, resulted in a CKE with the corresponding value.
BTW, your aspx file had a registered assembly "AjaxControlToolkit" which was not in use, I removed it. I do not know if this somehow affected this, but maybe you should give it a try.
Another thing: What browser are you testing this on, and do you see any javascript errors?
Well.. it actually does work.. I actually just made a sample of how it was failing in my project, and assumed it ad the same error.
But well tested it after you surprisely said that it worked. I then tried my solution again, and it didn't, very odd. I then moved the ckeditor.value around in my code and it worked everywhere i tried. I then moved it back where it was supposed to be, and it still work..
.. I'm sorry, really got no explanation why i didn't work before..
But thanks for your good work. Finally is the CKEditor for .net
Yes, sometimes ours PCs have a mind of their own... And the long waited CKEditor.Net really too-long waited. I'm surprised that the CK team did not do anything towards the .Net, and more surprised that they haven't sent any response on this particular control I made...
what i noticed with ckeditor is that everytime after a postback, it loses traction and config settings...
on every postback, the editor goes back to the standard config... so on every postback, i had to set it to use my custom config, this retained the toolbar set, skin..etc... but not the value
html_editor.CustomConfig = "custom_config.js"
hope this helps you solving this nasty bug
EDITED after postback, i can't seem to get the value of CKEditor at all!!!
NOTICED: -----> NO VALUE CAN BE CAPTURED WITH 2 UPDATE PANEL -----> POSTBACK IS CAUSED BY DROPDOWNLIST IN ANOTHER UPDATE PANEL
it seems if a control that is going to trigger a postback is inside any update panel, ckeditor in an updatepanel will lose its value, but if the control triggering the postback is not in any update panel ckeditor retains its value
eg... this will work <cc1:TabPanel runat="server" ID="TabPanel1" HeaderText="CKEditor"> <ContentTemplate> <asp:UpdatePanel ID="up_html_content" runat="server" UpdateMode="Conditional"> <ContentTemplate> <cc2:CKEditor ID="CKEditor1" runat="server" /> </ContentTemplate> </asp:UpdatePanel> <asp:DropDownList ID="ddl_template" runat="server" Width="164px" AutoPostBack="True" /> </ContentTemplate> </cc1:TabPanel>
I've done lots of debugging for the .NET ajax framework, and I found the real problem. When it does a postback with ajax, it iterates all 'known' elements in the form, concatenates the values into a QueryString and requests the postback link with the arguments. So the 'known' elements are of type 'INPUT', 'SELECT', and 'TEXTAREA'. Now of course we have a TEXTAREA in the form, but it does not get updated until a SUBMIT occurs. One of the differences between FCK 2 and CK 3, is that FCK was doing a value update on EACH AND EVERY change to the content, which was pretty heavy and unnecessary processing. Now CK 3.0 does the updates only on submit, but the AJAX onSubmit do not really trigger onsubmit.
So we have to find a way to make a workaround to cause CK 3.0 update the value all the time when it is inside an update panel, OR, somehow hack into .NET's AJAX and cause it to read the value of the CK when submitting.
Right now I can't think of a way, but we'll figure something out, whenever...
i've got a work around, not sure if you can implement it in the CKEditor control...
as i said before, the problem is caused by the control inside an update panel which causes the postback, but if control is outside the update panel it will work...
here is my work around...
have the control (in this case its a dropdownlist) handle a hidden button's postback click event, but the hidden button is outside the update panel
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click If ddl_template.SelectedValue = 0 Then CKEditor1.Toolbar = "Full" Else CKEditor1.Toolbar = "Basic" End If up_html_content.Update() End Sub
we are handling the Button1 click with onChange with the dropdownlist, because the button is outside of the update panel, it works perfectly, its a bit ugly, but its a work around...
so if you want a button to cause the postback, instead of onChange (for dropdownlist and some other controls, use onClick
@danielgindi hope this will help you code a work around on the ckeditor .net control
This is not very good... For a simple reason: A postback from outside the panel triggers the direct submit() of the form, which is nice, but it is cancelling the AJAX Postback effect... It send the whole page... For nice little pages it happens to fast to notice, especially locally, but on a little heavier or longer pages you will notice the page reloading...
i agree daniel, but its the only work around I could think of... if the dropdownlist was to be populated on the page by some other functions (new value), this is one way to have it working if its inside an update panel
do we have anyone from the CKTeam to shed some light on resolving this matter?
OK, I've just fixed it! With the magical Page.ClientScript.RegisterOnSubmitStatement. This one registers a script to be called on submit, which MsAJAX calls also when it does an AJAX postback, without a form.submit().
Try it now!
BTW, I removed previous versions because there's a limit on 3 attachments max. Let's see how fast the downloads numbers go up.
the following errors are extracted from Firefox 3.6
1st error.... this happens when i click on the close button, it sometimes runs into this error, and sometimes it works... Error: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500 line: this._endPostBack(this._createPageRequestManagerServerError(sender.get_statusCode()), sender, null);
2nd error... this happens when the show button is in a different update panel from the editor.. code.. <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <cc1:CKEditor ID="CKEditor1" runat="server" /> <asp:Button ID="btn_close" runat="server" Text="Close" /> </ContentTemplate> </asp:UpdatePanel> <asp:UpdatePanel ID="UpdatePanel2" runat="server"> <ContentTemplate> <asp:Button ID="btn_show" runat="server" Text="Show" /> </ContentTemplate> </asp:UpdatePanel>
Error: document.getElementById("CKEditor1") is null Source File: http://localhost:50887/CKEditor_Upload/Default.aspx Line: 47 if (CKEDITOR && CKEDITOR.instances && CKEDITOR.instances.CKEditor1) {document.getElementById('CKEditor1').value=CKEDITOR.instances.CKEditor1.getData();};
3rd error... this happens when the show button is in the same update panel as the editor I Noticed this only happens after a postpack has occured, so 2+ postback, it will not occur on the 1st postback
Hi! I'll look into your bugs later or tomorrow! Do you know if there really is an "enable" config in CKEditor? I'm not sure there is... If so, I will implement it. But otherwise - You will have to ask for a readOnly feature from the CK team
The second error - easly fixed. Will be OK in the next uploaded version... But first things first.
That bug with the error on Close button, is happening only when there's a value... So something is getting messed up in the AJAX mechanism, still don't know what it is. I'm trying to find a way to debug, and in the meantime, if you have any ideas - don't hesitate...
I've just fixed the last 3 bugs! They all come from the same bug... That thing about properly cleaning up the CKEditor. Execpt for that 500 error bug, which happens because we didn't HTML encode the value when registering with MsAjax OnSubmit. (That is fixed too of course)
About cleaning up: CKEDITOR.remove just removes the instance from its array, but do not clean up anything. [editor].destroy() is what cleans up everything. The problem with destroy() is that it fails if calling after a postback (when the old CKEDITOR do not really exist), And we do not wan't to actually remove the CKEDITOR before postback, because then the editor will disappear before the page is 'refreshed', and this is not a desirable effect. So I dug into CK's source, and found that the important thing is the fire('destroy'). Because CKEDITOR is registering OnSubmit events, and they register with 'destroy' in order to remove themselves, we need to raise the 'destroy' event in order for those events to clean-up. Then we CKEDITOR.remove, and walla! We cleaned up CKEDITOR's resources before actually removing it. (When the postback returns, MsAjax removes the CKEDITOR's elements from the page, which finalizes the cleanup)
Re: Have made Asp.Net Server Control!
i noticed if the button is outside the update panel, then it works with no problems (hope that helps solving why it doesn't work when buttton is inside the updatepanel)
Re: Have made Asp.Net Server Control!
Re: Have made Asp.Net Server Control!
try this scenario
you have 2 update panels and want to change the toolbar/styles in the editor
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<cc1:CKEditor ID="CKEditor1" runat="server" BasePath="~/ckeditor/" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
CKEditor1.Toolbar = "Basic"
UpdatePanel1.Update()
End Sub
AND if you move the editor out of the update panel it won't work
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<cc1:CKEditor ID="CKEditor1" runat="server" BasePath="~/ckeditor/" />
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
CKEditor1.Toolbar = "Basic"
End Sub
I know you can change the toolbar/styles of the editor IF there were no update panels on the page....
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<cc1:CKEditor ID="CKEditor1" runat="server" BasePath="~/ckeditor/" />
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</form>
BUT
if we now have some data grids and dropdownlists, we need an update panel to only update those areas
Attachments:
Re: Have made Asp.Net Server Control!
CKEditor's javascript generated an error that the "instance already exists".
So we need to remove the instance before telling it again to replace the textbox with the CKEditor, after every postback.
So now when there's MS Ajax available, I add javascript to check to see if there's an instance already, and if so - remove using CKEditor.remove(instance).
The problem now, is that the CKEditor has the most basic toolbar after postback, so the cleanup obviously isn't full. I do not know if there's better API for that, or if that is a CKEditor bug? Maybe someone please report this to the development team...
Re: Have made Asp.Net Server Control!
1 question... why did the build number go backwards?
the control released on 2010-01-21 was build 3.1.0.35312
apologies as i'm not a dll developer
Re: Have made Asp.Net Server Control!
Hi again,
I can confirm too that it work, at least partly:
A situation where it "fails" is where you have a dropdownlist set to autopostback and the ckEditor inside a updatepanel. When you then change the selected item in the dropdownlist and it make a postback which should set the value of the CKEditor, but the CKEditor remains empty!
Lets say in that dropdownlist we have to options: "Option 1" and "Option 2".
If you select Option 1 it should make a postback a set the CKEditor.value = "Option 1", and ofcause if you select Option 2 it should still make a postback and set the CKEditor.Value = "Option 2".
Am I able to set the CKEditors value in another way, or can this be fixed or something?
Btw. Thanks so far, you have really done a great job
Re: Have made Asp.Net Server Control!
Re: Have made Asp.Net Server Control!
They are both inside the same updatepanel..
It worked with the FCKEditor, so it shouldnt be my code
Re: Have made Asp.Net Server Control!
About the build number, I have no idea, it is automatically generated when you specify * instead of specific build, and that is the case...
About the disappearing value - Still have no idea. Please attach a full example of your situation that I can test.
CKEditor's inner engine AND API are entirely different than FCK. So the approach to making it .NET control must be different, and some problems are expected at this stage.
So we have two problems left to solve - the disappearing value, and the minimized toolbar.
Anyone has any idea how to properly cleanup the CKEditor instance before replacing it again?
Re: Have made Asp.Net Server Control!
Try this one..
Attachments:
Re: Have made Asp.Net Server Control!
I have tried with your project, and it works just fine. Tried with Chrome, IE8 and IE7.
Clicking either of the Option 1/Option 2, resulted in a CKE with the corresponding value.
BTW, your aspx file had a registered assembly "AjaxControlToolkit" which was not in use, I removed it. I do not know if this somehow affected this, but maybe you should give it a try.
Another thing: What browser are you testing this on, and do you see any javascript errors?
Re: Have made Asp.Net Server Control!
Well.. it actually does work..
I actually just made a sample of how it was failing in my project, and assumed it ad the same error.
But well tested it after you surprisely said that it worked. I then tried my solution again, and it didn't, very odd.
I then moved the ckeditor.value around in my code and it worked everywhere i tried. I then moved it back where it was supposed to be, and it still work..
.. I'm sorry, really got no explanation why i didn't work before..
But thanks for your good work. Finally is the CKEditor for .net
btw. was testing with chrome and IE8
Re: Have made Asp.Net Server Control!
And the long waited CKEditor.Net really too-long waited. I'm surprised that the CK team did not do anything towards the .Net, and more surprised that they haven't sent any response on this particular control I made...
Re: Have made Asp.Net Server Control!
error is happening with the control file released on 2010-01-22
say you have 2 tabs...
1 for the ckeditor and the other for changing the toolbar, or styles...etc..
after the postback, it lose the value
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<cc1:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0">
<cc1:TabPanel runat="server" ID="TabPanel1" HeaderText="CKEditor">
<ContentTemplate>
<asp:UpdatePanel ID="up_html_content" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<cc2:CKEditor ID="CKEditor1" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</cc1:TabPanel>
<cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="Dropdownlist Tab">
<ContentTemplate>
<asp:UpdatePanel ID="up_page_attributes" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="ddl_template" runat="server" Width="164px" AutoPostBack="True" />
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>
</div>
</form>
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
populate_ddl()
End If
End Sub
Private Sub populate_ddl()
ddl_template.Items.Clear()
ddl_template.Items.Add(New ListItem("full toolbar", 0))
ddl_template.Items.Add(New ListItem("basic toobar", 1))
ddl_template.DataBind()
End Sub
Protected Sub ddl_template_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddl_template.SelectedIndexChanged
If ddl_template.SelectedValue = 0 Then
CKEditor1.Toolbar = "Full"
Else
CKEditor1.Toolbar = "Basic"
End If
up_html_content.Update()
End Sub
End Class
attached is the page for the error,
danielgindi please have a look at the attached file, it seems after postback, the editor loses traction of the basepath, config...etc..
Attachments:
Re: Have made Asp.Net Server Control!
on every postback, the editor goes back to the standard config...
so on every postback, i had to set it to use my custom config, this retained the toolbar set, skin..etc... but not the value
html_editor.CustomConfig = "custom_config.js"
hope this helps you solving this nasty bug
EDITED
after postback, i can't seem to get the value of CKEditor at all!!!
NOTICED: ----->
NO VALUE CAN BE CAPTURED WITH 2 UPDATE PANEL -----> POSTBACK IS CAUSED BY DROPDOWNLIST IN ANOTHER UPDATE PANEL
eg...
<cc1:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0">
<cc1:TabPanel runat="server" ID="TabPanel1" HeaderText="CKEditor">
<ContentTemplate>
<asp:UpdatePanel ID="up_html_content" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<cc2:CKEditor ID="CKEditor1" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</cc1:TabPanel>
<cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="Dropdownlist Tab">
<ContentTemplate>
<asp:UpdatePanel ID="up_page_attributes" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="ddl_template" runat="server" Width="164px" AutoPostBack="True" />
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>
VALUE CAN BE CAPTURED IF DROPDOWNLIST IS OUTSIDE THE 2nd UPDATE PANEL...
eg...
<cc1:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0">
<cc1:TabPanel runat="server" ID="TabPanel1" HeaderText="CKEditor">
<ContentTemplate>
<asp:UpdatePanel ID="up_html_content" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<cc2:CKEditor ID="CKEditor1" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</cc1:TabPanel>
<cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="Dropdownlist Tab">
<ContentTemplate>
<asp:DropDownList ID="ddl_template" runat="server" Width="164px" AutoPostBack="True" />
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>
Re: Have made Asp.Net Server Control!
Re: Have made Asp.Net Server Control!
here you go
Attachments:
Re: Have made Asp.Net Server Control!
found another problem...
<cc1:TabPanel runat="server" ID="TabPanel1" HeaderText="CKEditor">
<ContentTemplate>
<asp:UpdatePanel ID="up_html_content" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<cc2:CKEditor ID="CKEditor1" runat="server" />
<asp:DropDownList ID="ddl_template" runat="server" Width="164px" AutoPostBack="True" />
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</cc1:TabPanel>
it seems if a control that is going to trigger a postback is inside any update panel, ckeditor in an updatepanel will lose its value, but if the control triggering the postback is not in any update panel ckeditor retains its value
eg... this will work
<cc1:TabPanel runat="server" ID="TabPanel1" HeaderText="CKEditor">
<ContentTemplate>
<asp:UpdatePanel ID="up_html_content" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<cc2:CKEditor ID="CKEditor1" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:DropDownList ID="ddl_template" runat="server" Width="164px" AutoPostBack="True" />
</ContentTemplate>
</cc1:TabPanel>
Re: Have made Asp.Net Server Control!
When it does a postback with ajax, it iterates all 'known' elements in the form, concatenates the values into a QueryString and requests the postback link with the arguments.
So the 'known' elements are of type 'INPUT', 'SELECT', and 'TEXTAREA'. Now of course we have a TEXTAREA in the form, but it does not get updated until a SUBMIT occurs.
One of the differences between FCK 2 and CK 3, is that FCK was doing a value update on EACH AND EVERY change to the content, which was pretty heavy and unnecessary processing. Now CK 3.0 does the updates only on submit, but the AJAX onSubmit do not really trigger onsubmit.
So we have to find a way to make a workaround to cause CK 3.0 update the value all the time when it is inside an update panel,
OR, somehow hack into .NET's AJAX and cause it to read the value of the CK when submitting.
Right now I can't think of a way, but we'll figure something out, whenever...
Re: Have made Asp.Net Server Control!
as i said before, the problem is caused by the control inside an update panel which causes the postback, but if control is outside the update panel it will work...
here is my work around...
have the control (in this case its a dropdownlist) handle a hidden button's postback click event, but the hidden button is outside the update panel
it would look like this...
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:Button ID="Button1" runat="server" Text="Button" style="display: none;" />
<cc1:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0">
<cc1:TabPanel runat="server" ID="TabPanel1" HeaderText="CKEditor">
<ContentTemplate>
<asp:UpdatePanel ID="up_html_content" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<cc2:CKEditor ID="CKEditor1" runat="server" />
<asp:DropDownList ID="ddl_template" runat="server" Width="164px" AutoPostBack="True"
onChange="Button1.click();" />
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>
</div>
</form>
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If ddl_template.SelectedValue = 0 Then
CKEditor1.Toolbar = "Full"
Else
CKEditor1.Toolbar = "Basic"
End If
up_html_content.Update()
End Sub
we are handling the Button1 click with onChange with the dropdownlist,
because the button is outside of the update panel, it works perfectly, its a bit ugly, but its a work around...
so if you want a button to cause the postback, instead of onChange (for dropdownlist and some other controls, use onClick
@danielgindi
hope this will help you code a work around on the ckeditor .net control
Re: Have made Asp.Net Server Control!
Any other ideas?
Re: Have made Asp.Net Server Control!
if the dropdownlist was to be populated on the page by some other functions (new value),
this is one way to have it working if its inside an update panel
do we have anyone from the CKTeam to shed some light on resolving this matter?
Re: Have made Asp.Net Server Control!
OK, I've just fixed it! With the magical Page.ClientScript.RegisterOnSubmitStatement. This one registers a script to be called on submit, which MsAJAX calls also when it does an AJAX postback, without a form.submit().
Try it now!
BTW, I removed previous versions because there's a limit on 3 attachments max. Let's see how fast the downloads numbers go up.
Re: Have made Asp.Net Server Control!
hi daniel,
yes the value is now there after a postback
but have found another 3 more bugs...
the following errors are extracted from Firefox 3.6
1st error.... this happens when i click on the close button, it sometimes runs into this error, and sometimes it works...
Error: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
line: this._endPostBack(this._createPageRequestManagerServerError(sender.get_statusCode()), sender, null);
2nd error... this happens when the show button is in a different update panel from the editor..
code..
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<cc1:CKEditor ID="CKEditor1" runat="server" />
<asp:Button ID="btn_close" runat="server" Text="Close" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Button ID="btn_show" runat="server" Text="Show" />
</ContentTemplate>
</asp:UpdatePanel>
Error: document.getElementById("CKEditor1") is null
Source File: http://localhost:50887/CKEditor_Upload/Default.aspx
Line: 47
if (CKEDITOR && CKEDITOR.instances && CKEDITOR.instances.CKEditor1) {document.getElementById('CKEditor1').value=CKEDITOR.instances.CKEditor1.getData();};
3rd error... this happens when the show button is in the same update panel as the editor
I Noticed this only happens after a postpack has occured, so 2+ postback, it will not occur on the 1st postback
code:
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<cc1:CKEditor ID="CKEditor1" runat="server" />
<asp:Button ID="btn_close" runat="server" Text="Close" />
<asp:Button ID="btn_show" runat="server" Text="Show" />
</ContentTemplate>
</asp:UpdatePanel>
Error: i.contentWindow is null
Source File: http://localhost:50887/CKEditor_Upload/ ... keditor.js
Line: 18
default:j.unselectable='on';}}},getPositionedAncestor:function(){var i=this;while(i.getName()!='html'){if(i.getComputedStyle('position')!='static')return i;i=i.getParent();}return null;},getDocumentPosition:function(i){var D=this;var j=0,k=0,l=D.getDocument().getBody(),m=D.getDocument().$.compatMode=='BackCompat',n=D.getDocument();if(document.documentElement.getBoundingClientRect){var o=D.$.getBoundingClientRect(),p=n.$,q=p.documentElement,r=q.clientTop||l.$.clientTop||0,s=q.clientLeft||l.$.clientLeft||0,t=true;if(c){var u=n.getDocumentElement().contains(D),v=n.getBody().contains(D);t=m&&v||!m&&u;}if(t){j=o.left+(!m&&q.scrollLeft||l.$.scrollLeft);j-=s;k=o.top+(!m&&q.scrollTop||l.$.scrollTop);k-=r;}}else{var w=D,x=null,y;while(w&&!(w.getName()=='body'||w.getName()=='html')){j+=w.$.offsetLeft-w.$.scrollLeft;k+=w.$.offsetTop-w.$.scrollTop;if(!w.equals(D)){j+=w.$.clientLeft||0;k+=w.$.clientTop||0;}var z=x;while(z&&!z.equals(w)){j-=z.$.scrollLeft;k-=z.$.scrollTop;z=z.getParent();}x=w;w=(y=w.$.offsetParent)?new h(y):null;}}if(i){var A=D.getWindow(),B=i.getWindow();if(!A.equals(B)&&A.$.frameElement){var C=new h(A.$.frameElement).getDocumentPosition(i);j+=C.x;k+=C.y;}}if(!document.documentElement.getBoundingClientRect)if(b.gecko&&!m){j+=D.$.clientLeft?1:0;k+=D.$.clientTop?1:0;}return{x:j,y:k};},scrollIntoView:function(i){var o=this;var j=o.getWindow(),k=j.getViewPaneSize().height,l=k*-1;if(i)l+=k;else{l+=o.$.offsetHeight||0;l+=parseInt(o.getComputedStyle('marginBottom')||0,10)||0;}var m=o.getDocumentPosition();l+=m.y;l=l<0?0:l;var n=j.getScrollPosition().y;if(l>n||l<n-k)j.$.scrollTo(0,l);},setState:function(i){var j=this;switch(i){case 1:j.addClass('cke_on');j.removeClass('cke_off');j.removeClass('cke_disabled');break;case 0:j.addClass('cke_disabled');j.removeClass('cke_off');j.removeClass('cke_on');break;default:j.addClass('cke_off');j.removeClass('cke_on');j.removeClass('cke_disabled');break;}},getFrameDocument:function(){var i=this.$;try{i.contentWindow.document;}catch(j){i.src=i.src;if(c&&b.version<7)window.showModalDialog('javascript:document.write("<script>window.setTimeout(function(){window.close();},50);</script>")');}return i&&new g(i.contentWindow.document);},copyAttributes:function(i,j){var p=this;var k=p.$.attributes;j=j||{};for(var l=0;l<k.length;l++){var m=k[l],n=m.nodeName.toLowerCase(),o;if(n in j)continue;if(n=='checked'&&(o=p.getAttribute(n)))i.setAttribute(n,o);else if(m.specified||c&&m.nodeValue&&n=='value'){o=p.getAttribute(n);if(o===null)o=m.nodeValue;
hope this helps on solve the remaining bugs for the .net control
Attachments:
Re: Have made Asp.Net Server Control!
i have tried ckeditor.enable = false
but .enable does not exist
Re: Have made Asp.Net Server Control!
I'll look into your bugs later or tomorrow!
Do you know if there really is an "enable" config in CKEditor? I'm not sure there is... If so, I will implement it. But otherwise - You will have to ask for a readOnly feature from the CK team
Re: Have made Asp.Net Server Control!
That bug with the error on Close button, is happening only when there's a value... So something is getting messed up in the AJAX mechanism, still don't know what it is.
I'm trying to find a way to debug, and in the meantime, if you have any ideas - don't hesitate...
Re: Have made Asp.Net Server Control!
I've just fixed the last 3 bugs!
They all come from the same bug... That thing about properly cleaning up the CKEditor.
Execpt for that 500 error bug, which happens because we didn't HTML encode the value when registering with MsAjax OnSubmit. (That is fixed too of course)
About cleaning up: CKEDITOR.remove just removes the instance from its array, but do not clean up anything.
[editor].destroy() is what cleans up everything.
The problem with destroy() is that it fails if calling after a postback (when the old CKEDITOR do not really exist),
And we do not wan't to actually remove the CKEDITOR before postback, because then the editor will disappear before the page is 'refreshed', and this is not a desirable effect.
So I dug into CK's source, and found that the important thing is the fire('destroy'). Because CKEDITOR is registering OnSubmit events, and they register with 'destroy' in order to remove themselves, we need to raise the 'destroy' event in order for those events to clean-up. Then we CKEDITOR.remove, and walla! We cleaned up CKEDITOR's resources before actually removing it. (When the postback returns, MsAjax removes the CKEDITOR's elements from the page, which finalizes the cleanup)
So now EVERYTHING should be OK.
Re: Have made Asp.Net Server Control!
great work!!!
you've solved all 3 bugs mentioned!!!!
i'll let you know if i encounter anymore nasty buggers
Re: Have made Asp.Net Server Control!
Had just found and made a "Sample error", when I saw you just have fixed it all..
Another thank you!