dotnetnukedotnetnuke-moduleradeditor

Referencing the DNN editor from outsite a DNN solution


I'm building a DotNetNuke module and I need to include the html editor. However, my modules are in a stand alone solution that xcopy's to my DNN install (I'm following the Visual Studio project templates for making modules). All the sample code I've seen references the text editor like so:

<%@ Register TagPrefix="dnn" TagName="TextEditor" Src="~/controls/TextEditor.ascx" %>

<dnn:TextEditor ID="txtDescription" runat="server" Width="100%" Height="300px" />

The problem is that since the modules are being developed outside of DNN, the reference to TextEditor obviously breaks the build.

Plan B was to instantiate the editor dynamically through a placeholder control like so:

EditorProvider editorProvider = new EditorProvider();
var control = editorProvider.HtmlEditorControl;

control.ID = "txtDescription";
phEditor.Controls.Add(control);

This kind of works, but most of the toolbar buttons are messed up!

DNN Editor bug

Any help would be greatly appreciated!


Solution

  • After some swearing and headbanging, I found the easy answer of just instantiating the usercontrol instead of the editor server control.

    var control = this.LoadControl("~/controls/TextEditor.ascx");
    control.ID = "txtDescription";
    phEditor.Controls.Add(control);