Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

telerik -- supercharge your DNN websites
  Ads  
Aspose - The .NET & Java component publisher
 


  Sponsors  

Meet Our Sponsors

The Official Microsoft ASP.NET Website
Portal Webhosting - Hosting For Developers
Red-Gate Software
MaximumASP
SourceGear - Tools for Developers
.: CounterSoft :.
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Extend It! ( Pr...  How to dynamically load a module
Previous Previous
 
Next Next
New Post 7/24/2008 9:21 AM
Resolved
User is offline lister
6 posts
10th Ranked


How to dynamically load a module 

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 10:05 AM
Accepted Answer 
User is offline William Severance
842 posts
www.wesnetdesigns.com
7th Ranked






Re: How to dynamically load a module 

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
 
New Post 7/31/2008 9:46 AM
User is offline Johnny Li
87 posts
10th Ranked


Re: How to dynamically load a module 

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 2:53 PM
User is offline Carlos Rodriguez
526 posts
www.almacigo.com
8th Ranked


Re: How to dynamically load a module 
Modified By Carlos Rodriguez  on 7/31/2008 4:56:07 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 2:55 PM
User is offline Michael Washington
2842 posts
ADefWebserver.com
5th Ranked










Re: How to dynamically load a module 

Als see:

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

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



Michael Washington
* ADefWebserver.com
* DNN Module Developer's Guide
* IWEB - DNN Web Services
* Silverlight and DotNetNuke
 
Previous Previous
 
Next Next
  Forum  General DotNetN...  Extend It! ( Pr...  How to dynamically load a module
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, 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 DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


OnyakTech
Modules for Help Desks, Live Chat, Project Management, CRM, Charting, Reporting, Scrolling Text/Images, Portal Community tools and much more.
www.OnyakTech.com
IHostASP.NET Provides the Ideal DNN Hosting
We will help you with the installation, configuration, and troubleshooting of your DNN portal, no task is too big or small for us. Unlike other companies we are not just providing a reliable hosting service, but we are also focused on providing the best DotNetNuke hosting service on the internet.
www.ihostasp.net
$7.16/mo - Powerful DotNetNuke / DNN Hosting
Powerful DotNetNuke / DNN Hosting on Windows 2008 and 2003 servers, starting at under $8/mo with FREE SQL 2008 on certain plans and FREE SQL 2005 on all plans with FREE Installation and expert support.
www.re-invent.com

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP