Wednesday, March 24, 2010

HTML Editors in DNN Modules

You might need to include a HTML editor in a particular module as a mean of providing a good content editing experience to the users. There are many very good commercial options including CuteSoft. I needed a free option and the most straight forward thing I could find is to use the DNN default text editor it self.

DNN 5 by default uses the FCKEditor. However it is integrated under a flexible provider model which allows developers to plug in different HTMLEditors (even commercial ones) without changing the core modules.

So things looked pretty straight forward and I just had to use <dnn:texteditor> markup (A control which was introduced with the above provider model enhancement) within my module (ascx file) to include the HTMLEditor control. And here lies the problem. The <dnn:texteditor> markup actually boils down to a control named 'TextEditControl' and the steps to include this is no different to general ASP.Net way, which is using Register Directives on top of the page/control;

1. Reference the relevant assembly (<%@ Register TagPrefix="ControlVendor" Assembly="AseemblyName" %>)
2. Add a reference to the control (<%@ Register TagPrefix="TextEditor" TagName="header" Src="Controls/ControlName.ascx" %>

(There's a better way proposed by Scott Gu here)

Now the problem with TextEditControl is that the same control (name) can be found in 2 DNN assemblies. Worst part is these 2 are different as well. I think one of them is a residue from previous DNN versions or may be they actually have real purpose. But why the hell can't they name the controls differently?

The proper one to use in this instance is the TextEditControl from 'DotNetNuke.UI.UserControls'. So make sure you refer to that assembly in your module (ascx file).

So it was hard toiling for a few hours before I caught this and it once again emphasized the real need of good documentation for DNN.

Some more tips on TextEditControl
Post a Comment