Hi guys!
Great news! There's an official .Net control at work, and I'm part of it. And it is now working very well, so, download it here: http://ckeditor.com/download.
I have spent some time now to created a server control for ASP.NET, in the same manner as the FCKeditor2 control.
I'm keeping always the last 3 versions attached to this post, as this is the maximum for the form. And no I do not have the time to keep a blog or a 'project' in 'github' or its equivalents.
Click here to download the latest version
Basics how to use:
- Put the FredCK.CKEditor.dll in your /Bin folder (You can find it in bin/Release in the Zip package)
- Register the control with either or even both methods:
- Globally, in web.config: <add tagPrefix="FredCK" namespace="FredCK.CKEditor" assembly="FredCK.CKEditor, Culture=neutral, PublicKeyToken=9ef91de3e191403a" />
- Per page: <%@ Register Assembly="FredCK.CKEditor" Namespace="FredCK.CKEditor" TagPrefix="FredCK" %>
- Put a FredCK.CKEditor on your page...
- The only REQUIRED attribute is BasePath. It points to the ckeditor folder. It defaults to "~/ckeditor/", so if this is your cke folder, you do not even have to specify this. Another option to set BasePath globally to ALL CKEditor controls in your app, is to set a CKEditor:BasePath key in your app.config, with the value pointing to the ckeditor folder.
Re: Have made Asp.Net Server Control! (And little help needed)
StartupMode should not be an enumeration - see the API.
ToolbarName should not be an enumeration - see the API.
ToolbarLocation should not be an enumeration - see the API.
Though I can just about see there being a desire to maintain compatibility with 1.1, client state that the control relies upon should be stored in .NET ControlState, not ViewState.
It is wrong that you have marked the files as developed by yourself, as they are very clearly in part copies of the original source available from the FCK Editor site, as well as in part derivative works.
The ClientScriptManager can handle the setting of client on submit events, a reference to which can be gleaned from 'this.Page.ClientScript'. Best practice dictates you need to first ensure that the control does not partake in a partial page update contract before that however, and if it does your escape operation must use other means.
The 'ExtraPlugins' property. Not sure why you have done this but the assignment operator will append to this property if the underlying data store has already been set. This is a clear example of unexpected operation.
You can programmatically devine an enumerations' name in .NET, for example to use with your 'ShiftEnterMode' property. For instance somthing along the lines of (from memory): Enum.GetName(typeof(EnterMode), (int)value)).
Regards
Re: Have made Asp.Net Server Control! (And little help needed)
Thanks for your comments!
About ClientScriptManager - I tried to register a javascript for the OnSubmit of the form, but its no use, because it happens BEFORE the CKEditor copies the content to the textarea. To make sure it always happens we need to make it controlled by the CKEditor itself, otherwise we will have to make a 80 lines script instead of a 1 line script in order to maintain compatibility with all browsers...
The extraPlugins is working fine by my tests. It is supposed to add to the existing list or make a new one. An existing list is there when you have set the uiColor property (which registers an extraPlugin...). There's nothing unexpected there (just not documented yet by me)
I do not know why you are saying that it is not coded by myself, as 99% of this code I did write. You have any idea how much time it takes to move all configuration properties, each one with its type and description, from the documentation to the actual code? And the basic code of the control was mostly also rewritten by me, even though it might seem the same. I did try at first to make it compatible with the FCKeditor .Net control, but when I got to the configurations, I realized thats not gonna happen...
The only thing that I recall I have taken from the original code, is the file structure (without the 'F'), and the html string for the Designer.
I know that StartupMode, ToolbarName and ToolbarLocation should not be Enum, but it is convenient for the time being, when I haven't yet added support for all those array based configurations. So for now it gives the basic functionality that most people will use.
As for ViewState vs ControlState - As I understand it, the difference is that ControlState cannot be disabled by the user. But isn't ViewState the 'standard' in server controls for this purpose?
As for "Enum.GetName(typeof(EnterMode), (int)value))." - I do not need to do that actually. If I wanted to get the string name of the enum value, I could just use ToString().
But I'm originally a C++ developer, and I tend to always do "error checking", and by a C++ developer logic, you know that there can be cases where an enum will have a value which is not in the Value-Name list, so I use switch-case for that. I'm not sure how C# handles these cases, but I'm not sure either if I'll actually gain any performance from converting directly to string.
Bottom line - the first thing we have to do, is figure out the best way to encode the html before submit, after the editor has copied its content to the textarea. (Which is probably registered with the browser for the onsubmit event).
After that - we'll handle all the rest of the work to be done with the configurations.
And then - integrating the file browser/uploader.
Thanks again for commenting on this! I did expect a lot more responses on this one, but you are the only one so far...
Re: Have made Asp.Net Server Control! (And little help needed)
Re: Have made Asp.Net Server Control! (And little help needed)
Hi,
while there is no native support for the HtmlEncode like in FckEditor 2.x you could use the following technique: http://www.blogfor.net/2008/04/19/detecting-and-avoiding-a-potentially-dangerous-requestform-value-was-detected-from-the-client-in-aspnet/
Does anyone knows, if there are any plans for a native HtmlEncode-Support ?
Greetings,
Sven
Re: Have made Asp.Net Server Control! (And little help needed)
Re: Have made Asp.Net Server Control! (And little help needed)
What I need exactly for this is a way to encode the 'critical' html entities before form submission. (Which are the <>& (< > &), just 3 characters.
Because ASP.NET won't allow those characters to be posted as they are, they need to be converted to the html entities.
So we just have to run a simple replace before post.
How do I approach this?
I tried already writing a little script in OnSubmit, but it didnt work. Seems like CKEditor registers that event, and If I register it too, I cannot have guarantee for the order in which the callbacks will be called.
Re: Have made Asp.Net Server Control! (And little help needed)
Re: Have made Asp.Net Server Control! (And little help needed)
Man thats simple
Re: Have made Asp.Net Server Control! (And little help needed)
But its not working
I tried to set entities to true, and to false, both has no effect.
Tried also entities_additional as 'amp,lt,gt', and still no effect...
Re: Have made Asp.Net Server Control! (And little help needed)
Re: Have made Asp.Net Server Control! (And little help needed)
I have tried using the CKEditor.on(...) method to register the event on getData, but that is turned out to be terrible, because preview plugin also uses getData, and then when CKEditor first loads, it encode the HTML entities too so everything breaks....
After some trial I have found a way to change CKEditor to encode its output before submit, without breaking the CKEditor. I'm overriding its updateElement and calling the original method with a light change - when updateElement calls getData it will get an encode data.
So now everyone can use CKEditor within ASP.NET in the same manner they used FCKEditor!
I'm attaching my code and compile DLL (within Release folder).
Attachment is at the first post.
Re: Have made Asp.Net Server Control!
My latest comments are in the original post.
Re: Have made Asp.Net Server Control!
Thank you for all work you have done. I have some question:
1. Will this server control be the "official" server control for ckeditor?
2. I have some problem with updatepanels, when using updatepanels the toolbar disappear, if you remove the updatepanel it will work as it should. I send you an example where I have your control inside an update panel.
3. For what/How do you use the control CKSharedSpace?
Attachments:
Re: Have made Asp.Net Server Control!
Everything seems to work relative to adding taxt and saving ot to a database.
I am unable to see any toolbars. Any ideas?
Here is the control I have on my page:
<cc1:CKEditor ID="CKEditor1" runat="server" BasePath="~/ckeditor" ToolbarStartupExpanded="True" ToolbarLocation="Top" BaseHref="~/" EnterMode="P" FileBrowserImageBrowseUrl="~/images" FileBrowserImageUploadUrl="~/images" Skin="kama" ToolbarCanCollapse="False">
</cc1:CKEditor>
Thanks!
Re: Have made Asp.Net Server Control!
same here, i can't seem to see the toolbar... anyone solved this?
edited:
never mind, figured it was BasePath="~/ckeditor/", you need to have this in the control
Re: Have made Asp.Net Server Control!
Re: Have made Asp.Net Server Control!
I apologize for the delay in my response, it is just that I forgot to check the "Notify me when a reply is posted", and I did not get any emails...
I think you may have missed the BasePath property. You have to tell it where is the actual CKEditor folder... usually it is at ~/ckeditor/.
<FredCK:CKEditor ID="ckContent" runat="server" Language="he" Height="500" Width="665" BasePath="~/ckeditor/" />
There may be a bug when the basePath is not / terminated, I'll check that out.
Anyway, regarding the shared space control, it is basically a DIV container. What you do is put that control where you want the toolbar or the status bar. Then in the ckeditor you specify the control id of the shared space in the SharedSpacesTop/SharedSpacesBottom, or if you have a div which is not a server control, you can put its id in SharedSpacesTopClientID if SharedSpacesBottomClientID.
ckeditor takes care of the rest.
The shared space is any space that you wish to put your toolbar there (or that bottom status bar). I wrote the extra control just for anyone who wants to distinguish between other divs and controls to the place where they put the toolbar...
Regarding the question if this is gonna be the official control - I have no idea. I was not contacted by anyone of the CKEditor team until now. As I stated before I have no problem with my control being the official one and being updated regularly by the actual ckeditor team.
Re: Have made Asp.Net Server Control!
Hello there,
First of all thanks for this great control to .net
I though think I found a bug:
When the CKEditor is inside an update panel and you trigger the update panel, the editor change to a regular textbox.. All the buttons and the WYSIWYG function is gone..
Any idea?
Regards,
Jeppe
Re: Have made Asp.Net Server Control!
Truth is I never used Update Panels so I do not know yet how they work and where the problem could be.
I'll check it out.
Can you send me a 'working' example?
Re: Have made Asp.Net Server Control!
Well just create a standard website and put this in the form
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
Editor here + a button to postback or something
</ContentTemplate>
</asp:UpdatePanel>
When it loads first time with the rest of the page there isn't any problems, but when make postback..
Well if you never used it before: http://www.asp.net/Ajax/Documentation/L ... rview.aspx
Re: Have made Asp.Net Server Control!
I know the principles how it should work, what I mean to say is I do not know its exact underlying mechanism.
Anyway I'm checking this out now
Re: Have made Asp.Net Server Control!
I tried registering the scripts with the ScriptManager when MS AJAX is available, but what happens is that MS AJAX is waiting for a callback from the ckeditor.js...
I have made added a workaround which will register the ckeditor.js on the OnInit event when there's MS AJAX, because we want to load it the 'simple' way. And it will register it only in the PreRender event when there's no MS AJAX.
In addition the CKEDITOR.replace will be called using the RegisterStartupScript of the ScriptManager when there's MS AJAX.
Try it now and tell me how it works for you!
Re: Have made Asp.Net Server Control!
Hi there Daniel,
Really great that you work this fast
I have tried with the new version of the control, and I'm sorry to inform that it doesn't work..
Instead of showing an empty textbox(as before), it completely disappear when you do a postback in the update panel.
Does that make any sense?
Re: Have made Asp.Net Server Control!
So if the script is not executed - there should be a textbox as before. If it does - there should be a CKEditor...
If you have google chrome installed, its a good tool to debug and see what happened.
I've tested my code with the example that is posted here a fews replies back, and it actually works!
One thing I can tell you that you should verify is that you have a ScriptManager on your page..
Re: Have made Asp.Net Server Control!
hi danielgindi
i confirm with marci,
control released on 2010-01-17 - textbox appears after postback
control released on 2010-01-21 - the editor disappears
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<cc1:CKEditor ID="CKEditor1" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Button" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
Re: Have made Asp.Net Server Control!
Which browser do you use?
Can you upload here a package of an example 'website' in which it doesnt work?
Re: Have made Asp.Net Server Control!
here is the page..
Default.zip
AjaxControlToolkit.dll 3.0.30512.0
FredCK.CKEditor.dll 3.1.0.35312
Attachments:
Re: Have made Asp.Net Server Control!
hi danielgindi


i got 2 question regarding ckeditor for .net
1.
how do i create custom toolbars and link them to the editor
i know that CKEditor1.Toolbar = "Full" or "Basic" works, but where can i manually create my toolbar
i've tried putting it in the ckeditor.js file
i.toolbar = 'CustomToolbar';
i.toolbar_CustomToolbar =
[
['FitWindow', 'ShowBlocks', '-', 'Preview', '-', 'Templates', 'Print', 'SpellCheck'],
['Bold', 'Italic', 'Underline', 'StrikeThrough', '-', 'Subscript', 'Superscript'],
['OrderedList', 'UnorderedList', '-', 'Outdent', 'Indent'],
['Undo', 'Redo', '-', 'Find', 'Replace'], ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyFull'],
['Link', 'Unlink'],
['Image', 'Flash', 'Table', 'Rule', 'SpecialChar'],
'/',
['Cut', 'Copy', 'Paste', 'PasteText', 'PasteWord'], ['Style', 'FontFormat', 'FontName', 'FontSize'],
['TextColor', 'BGColor']
];
and tried to CKEditor1.Toolbar = "CustomToolbar"
but that doesn't seem to work
EDITED:
i've putted in the config.js file
and it works
2.
create custom styles and link them to the editor...
the default style file is located in...
ckeditor/plugins/stylescombo/styles/default.js
CKEDITOR.addStylesSet('default',........
i've tried adding another line to the file so it now looks like
CKEDITOR.addStylesSet('custom_style', .......
in the code behind, i've tried
CKEditor1.StylesCombo_StylesSet = "default" ----> this works
CKEditor1.StylesCombo_StylesSet = "custom_style" ------> this doesn't work
EDITED:
i've putted in the config.js file
and it works
Re: Have made Asp.Net Server Control!
If you want to learn about all of the configurations of the cke, you can go to the docs. (Or look at the 'summary' of the configurations' set/get in my code)
Re: Have made Asp.Net Server Control!