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

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How to dynamically load a moduleHow to dynamically load a module
Previous
 
Next
New Post
7/24/2008 11:21 AM
 

I need to be able to load modules dynamically. I couldn't seem to find a function that would let me do this in the DotNetNuke source (and AddNewModule is protected) so I created a helper class to call the function for me. The issue is that when I call AddDynamicModule, the Request object isn't set. I believe this is because I'm creating the DynamicModuleLoader object after the request object is set, but I'm not positive. So the end result is I get into the AddNewModule in ControlPanelBase and I get an exception on this line 178( If Request.IsAuthenticated Then) because Request is null. I really don't want to have to modify any DotNetNuke source if I can help it (it makes upgrades a pain.) Thank you for your help!

I have created a new class called DynamicModuleLoader that inherits ControlPanelBase. Here is the code:

    Public Class DynamicModuleLoader
        Inherits ControlPanelBase

        Public Sub AddDynamicModule(ByVal title As String, ByVal desktopModuleId As Integer, ByVal paneName As String, ByVal position As Integer, ByVal align As String)
            MyBase.AddNewModule(title, desktopModuleId, paneName, position, ViewPermissionType.View, align)
        End Sub

    End Class

 

And here is the code in my module:

 

    public partial class View : DotNetNuke.Entities.Modules.PortalModuleBase
    {
        public static DynamicModuleLoader sHelper = new DynamicModuleLoader();

        protected void tvModuleTreeList_SelectedNodeChanged(object sender, EventArgs e)
        {
            TreeNode sNode = tvModuleTreeList.SelectedNode;
            int moduleId = isDynamicModule(sNode.Text);


            if( moduleId >= 0 )
            {
                Add
                sHelper.AddDynamicModule(sNode.Text, moduleId, "ContentPane", 1, "left" );
            }
        }
}

 
New Post
7/24/2008 12:05 PM
Accepted Answer 

Because ControlPanelBase inherits from UserControl, it (or rather a control inheriting from it) expects to be added to the page's control tree. Thus, I would not be surprised that it has received no HttpContext making the Request object null. Rather than trying to inherit from ControlPanelBase, I would suggest you take a look at the source code in ControlPanelBase.vb for the AddNewModule method and follow that in writing your own AddNewModule method. Most of the code will be in setting up an instance of Entities.Modules.ModuleInfo, creating the permissions and setting the other properties of ModuleInfo your situation needs, then calling the AddModule method of an instance of Entities.Modules.ModuleController.


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
7/31/2008 11:46 AM
 

How about creating a set of stored procedures that will add the module to the database and then run it when you want to add the dynamic module?

 

 
New Post
7/31/2008 4:53 PM
 

Lister:

I only wanted to share with you, in case you haven't seen it, the architecture I have successfully used to create modules with multiple user controls and only one view module.  Is this what you mean by dynamically loading modules?

Anyway, I have an architecture based on the code presented by by Indyne Inc. on their site in this link.  It is the concept of a main switchboard module and in it you dynamically load all the others based on your own logic.  In this way only the main module needs to be registered so basically you cannot navigate to all the user controls, only the main view control that is the switchboard.  This has worked for me well.

EDIT: Forgot to mention that opposite to what they say in their site, you do not need to register to download the sample from Indyne, just go to the downloads section and click on Switchboard on the tree on the left.

Hope this helps.

Carlos

 

 
New Post
7/31/2008 4:55 PM
 

Als see:

http://www.adefwebserver.com/DotNetNukeHELP/Misc/Dynamicforms.htm

and note the solution to: "Dynamically Loaded Controls Do Not Save v13wstat3".



Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How to dynamically load a moduleHow to dynamically load a module


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