Hi all,
I'm developing a new asp.net site for a client and I'm keen to integrate the new CKeditor within it to allow the client to customise areas of the site.
I've previously used FCKeditor and while this has been good I've always had problems integrating it into my style of admin pages (I extensively use popup panels to display record contents etc..).
I'm hoping that the new CKeditor will work better in this regard - however, I can't find any information on how to integrate it into an asp.net page (I realise it's still beta and that documentation will be coming...)
I was hoping that someone had already succesfully done this and might be willing to post information on how they did it (there's a good chance that I'm being dense and it is in fact obvious - if so please tell me, I've got broad shoulders
Thanks in advance.
Thu, 05/14/2009 - 16:11
#1
Re: CKeditor and asp.net
Hopefully, people can use it/refine it/comment on it and with a bit of luck tell me where I'm going wrong to resolve the couple of issues that I still have.
I have a page which displays a list of articles in a list view, clicking on an article displays an Ajax Toolkit popup extender panel with the details of the article - including the content, which needs to be HTML (hence the CKeditor). The details 'form' is made up of a formview with edit and insert modes.
This makes it more difficult as the CKeditor has to be created, populated and read depending on the state of the formview.
In the main aspx page
Here I've added an asp:literal within a textarea - the literal is bound to data from my Linq query and the textarea will be used to create the CKeditor.
The textbox (lb_Content) is there to 'get' the updated CKeditor content when the update is submitted (it may be that I could use the literal for this purpose but the textbox works so I'm happy with that).
codebehind page
In the onselectedindexchanged function for the listview I've added the following code:
Here I bind the formview to the selected article (there are probably neater ways of doing this - but this works and I have listviews embedded in other listviews which makes it complicated!)
At this point I inject the javascript to create the CKeditor (the default mode of the formview is 'edit' so I know the textarea exists)
Finally I get the 'submit' button and attach an attribute consisting of the javascript required to extract the data from the editor so that I can access it through the hidden textbox. (Initially I had this script registered as a toolscriptmanager onsubmit - but this was causing problem when the page was submitted from other controls - so the attribute on the button works best).
Existing Issues
I still have two problems which I can't seem to resolve:
1) On first load the CKeditor doesn't display the content - if I click on source I see the content in source view - if I click on submit the content is passed back to the server, so it's there just not being displayed. If I close the form and select another (or same) article the content of the newly selected article appears OK.
2) The formatting buttons (style, font, color etc..) don't have any text in them and when I select any of them nothing happens - all the other buttons work OK. I'm guessing this is something to do with the update panel that's surrounding the form.
If anyone has any ideas on how I can resolve these issues any thoughts are welcome.
I've only spent half a day looking at this to try and get the CKeditor to work - if anyone has any neater solutions or ideas how this can be improved, please add to this post. Since I can't find any other documentation on how to integrate into asp.net this could be helpful to anyone else trying to do something similar.
Re: CKeditor and asp.net
Frederico Knabben
CKEditor Project Lead and CKSource Owner
--
Follow us on: Twitter | Facebook | Google+ | LinkedIn
Re: CKeditor and asp.net
Re: CKeditor and asp.net
Bah ....
Re: CKeditor and asp.net
Re: CKeditor and asp.net
Re: CKeditor and asp.net
Re: CKeditor and asp.net
Re: CKeditor and asp.net
Such nice words from you.
Is this the way that you behave everywhere?
Re: CKeditor and asp.net
hopefully this satisfy your curiosity about my behaviour
Re: CKeditor and asp.net
ckEditor.ascx.cs
ckEditor.ascx
Re: CKeditor and asp.net
I am not sure if you fixed the issue or not but I found it, there is really easy trik you can do just give a runat="server" to the <textarea> then you can get or set the innerHTML property of the <textarea> from C# code but make sure to add the ValidateRequest="false" in the top of the page in <%@ Page attributes.
best,
naz
Re: CKeditor and asp.net
string ckEditorContent = Request[editor.ClientID.Replace("_","$");
In my case I use a User Control to house the CKEditor inside an AJAX Accordian, but that doesn't seem to matter at all. So if you have something like this:
<textarea runat="server" id="editor" name="editor">
</textarea>
and do the usual CKEditor javascript replacing (see other posts), then the code above will work. One line of code. Doesn't get much simpler than that.
Hope this helps.
Re: CKeditor and asp.net
hi, guys if any one is really interested in ckeditor with asp.net then
1. download my whole project from http://npcs2k7.110mb.com/CK_editor_.zip
2. or else view this webpage => http://www.codeproject.com/KB/edit/CK_EDITOR.aspx