0
votes

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!

3

3 Answers

1
votes

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);
0
votes

I am assuming you are developing a custom module for dotnetnuke, you can look at the example implementation in blog module source code on codeplex.com. EditEntry.ascx is the control that contains the same example.

Basically, You just need to reference DotNetNuke.dll and DotNetNuke.WebControls.dll to make it working inside ascx declaration.

0
votes

Found a better answer at http://www.dnnsoftware.com/forums/forumid/203/postid/466819/scope/posts from Hristo Evtimov.

His method lets you add attributes to the Text editor.

His code:

One way to do it is like this:

    DotNetNuke.UI.UserControls.TextEditor editor = (DotNetNuke.UI.UserControls.TextEditor)LoadControl("~/controls/texteditor.ascx");       
editor.ID = "Editor1";
this.Controls.Add(editor);

My code in VB.NET came out like this:

    Dim txtDescription As DotNetNuke.UI.UserControls.TextEditor = DirectCast(LoadControl("~/controls/texteditor.ascx"), DotNetNuke.UI.UserControls.TextEditor)
        txtDescription.ID = "txtAOneDescription" & intControlCounter.ToString
        txtDescription.HtmlEncode = False