Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Getting StartedGetting StartedProgrammatically adding HTMLEditor ControlProgrammatically adding HTMLEditor Control
Previous
 
Next
New Post
9/27/2010 12:54 PM
 
I'd like to add an HTMLEditor control to my page dynamically in C#, but can't seem to find the syntax.  Any help?

TIA,
Joel
 
New Post
9/27/2010 3:54 PM
 
Here's some code I've used in the past

protected TextEditor textContent;
 
 
textContent = (TextEditor)LoadControl("~/controls/TextEditor.ascx");
textContent.HtmlEncode = false;
textContent.TextRenderMode = "Raw";
textContent.Width = 500; //default values for size of the editor
textContent.Height = 500; //default values for size of the editor
textContent.ChooseMode = true;
 
//a placeholder on the ASCX side
phTextEditor.Controls.Add(textContent);
 
textContent.Text = "some content"

Chris Hammond
Former DNN Corp Employee, MVP, Core Team Member, Trustee
Christoc.com Software Solutions DotNetNuke Module Development, Upgrades and consulting.
dnnCHAT.com a chat room for DotNetNuke discussions
 
New Post
9/28/2010 9:40 AM
 
Excellent!  Now my problem is that when I try to set the value of the text, I get "Object reference not set to an instance of an object."

input = (TextEditor)LoadControl("~/controls/texteditor.ascx");
 ((TextEditor)input).Text = existingValue;

TIA,
Joel
 
New Post
9/28/2010 11:56 AM
 
So it turns out that you can't set the text before the control has been initialized. I added an Init event handler, but apparently I can't give it any EventArgs, so I ended up storing my value in a hashtable and setting it in the EventHandler. Is there a different kind of event handler that I can use to pass in the value? Next question. In the HTMLEditorProvider ConfigDefault.xml file I'm adding a CSS stylesheet via the CssFiles property, and a javascript function to call via the OnClientLoad property. How can I get this instance of the TextEditor to pick those up?
 
New Post
9/28/2010 1:08 PM
 
Sorry, I forgot to mention the load order, when loading the code I used in the example it was all done in OnInit for the control, before base.OnInit was called.

As for your CSS changes, if you're making changes to the way the TextEditor control for the HTML module (or other instances of the editor), it should be loading the same control for the new module if you use the code I provided. I take it you're not seeing that?

Chris Hammond
Former DNN Corp Employee, MVP, Core Team Member, Trustee
Christoc.com Software Solutions DotNetNuke Module Development, Upgrades and consulting.
dnnCHAT.com a chat room for DotNetNuke discussions
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Getting StartedGetting StartedProgrammatically adding HTMLEditor ControlProgrammatically adding HTMLEditor Control


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out