Using FCK Editor with ASP.NET MVC

First of, what is this FCKEditor? Well, it’s an HTML Text Editor. It’s free and open source, cross browser, extensible and there are probably quite a few more buzzwords applicable. Oh… and it’s also the default HTML Text Editor provided with DotNetNuke. Fck Editor is soon to be replaced by CK Editor but I’ll stick with Fck for now. CK will work mostly the same though.

You’ll need to copy the “editor” folder over to you Contents folder in you ASP.NET MVC website. I chose the path “/Content/Js/ Fck” to paste it in.

Two other files you might want to copy over to this same folder are in the root of the downoaded zipfile: fckeditor.js and fckconfig.js. The latter is expected by the editor and (suprisingly) contains configuration settings for the editor, while the first contains a few nice javascript functions to instanciate the editor.

Important thing here, is the name property of the TextArea being set to the same value as the Id of it.

To finish the client side of things off, you’l need to add some javascript to turn the textarea into a FckEditor at runtime. This can be copied from the samples of course, except for the Url.Contents part: