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...Building ExtensionsBuilding ExtensionsModulesModulesAccessing RADEditor From TextEditorAccessing RADEditor From TextEditor
Previous
 
Next
New Post
10/7/2015 11:01 AM
 

I have a module written for DNN 6.x that I am porting over to DNN 7.x

I came across a problem that I can't seem to figure out. I have code written (which worked perfectly in DNN 6.x) that took a DNN TextEditor control, and retrieved it's RADEditor control. I need to do this because I programatically make changes to the RADEditor's appearance for my module (ie: Show/Hide Tabs on-the-fly, update the SnippetsManager contents, update that ImageManager settings, etc.)

The problem I am getting now is stating: Unable to cast object of type 'DotNetNuke.RadEditorProvider.Components.DnnEditor' to type 'Telerik.Web.UI.RadEditor'

My code took the DNNTextEditor control, and then searched it for the RadDialogOpener control. From there I took the RadDialogOpener's parent which would equate to the RadEditor, which I could then manipulate as needed. However, not the RadDialogOpener's parent is a DNNEditor, and I can't seem to figure out how to get it's reference and use it. I tried changing my object that I am saving the parent into from Telerik.Web.UI.RadEditor to DotNetNuke.Web.UI.WebControls.DnnEditor...but that didn't work. I ended up getting this error: Unable to cast object of type 'DotNetNuke.RadEditorProvider.Components.DnnEditor' to type 'DotNetNuke.Web.UI.WebControls.DnnEditor'

I tried to define the object as , DotNetNuke.RadEditorProvider.Components.DnnEditor, but that definition doesn't exist. I am at my wits end and I am in a serious bind. I have to get this working next few days to avoid another major issue that will hit November 1st.

Cane anyone PLEASE help? 


Ben Santiago, MCP Certified & A+ Certified
Programmer Analyst
(SQL, FoxPro, VB, VB.Net, Java, HTML, ASP, JSP, VBS, Cognos ReportNet)
 
New Post
10/8/2015 2:34 PM
 
Ok, I figured out my own answer. I ended up comparing my old DNN6 Code to the new DNN7 Code, and I had to also download the DNN 7.4.1 Platform Source and review to code in the framework, and finally got a solution.

For anyone else having this same problem, do the following:

1) First perform a recursive search within the DNNTextEditor control for another control of the type Telerik.Web.Ui.RadEditor
- In DNN6 this usually returns a control, in DNN7 in most cases it returns nothing
2) Next, If you still have no control from the above code, then do a recursive search for a control of type Telerik.Web.UI.RadDialogOpener
- This should ALWAYS return to you a control object
A) Now that you have a RadDialogOpener control, take it's parent and cast it to a Telerik.Web.UI.RadEditor contol
- Note: You might notice that the parent of the RadDialogOpener Control is of type DnnEditor, don't worry as DnnEditor inherits from RadEditor so the type cast will work.

Now you can access the RadEditor controls and features through intelli-sense off the RadEditor object.

If you need to "test" to see if you successfully retrieved the RadEditor control reference, for DNN7 you have to perform a duel test:
((objControl.GetType() IsNot GetType(Telerik.Web.UI.RadEditor)) And (objControl.GetType().ToString() <> "DotNetNuke.RadEditorProvider.Components.DnnEditor"))

If the above line is TRUE, then you need to perform the recursive search as explained above. If the above line returns FALSE, then you have a valid RadEditor control reference.

I created methods to do the above recursive searching to make things easier and modular so you may want to consider doing the same.

Have fun coding!

Ben Santiago, MCP Certified & A+ Certified
Programmer Analyst
(SQL, FoxPro, VB, VB.Net, Java, HTML, ASP, JSP, VBS, Cognos ReportNet)
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesAccessing RADEditor From TextEditorAccessing RADEditor From TextEditor


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.

Content Layout

Subscribe to DNN Digest

DNN Digest is our monthly email newsletter. It highlights news and content from around the DNN ecosystem, such as new modules and themes, messages from leadership, blog posts and notable tweets. Keep your finger on the pulse of the ecosystem by subscribing.  


Copyright 2017 by DNN Corp Terms of Use Privacy
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out