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...Building ExtensionsBuilding ExtensionsModulesModulesHow To Get ModuleID?How To Get ModuleID?
Previous
 
Next
New Post
3/26/2012 9:35 AM
 

How do I retrieve the current Module's ID from a "Custom Class"?

I have a routine within a custom class that needs the current ModuleID, but the module has no direct access to the supplied ModuleID property of a ModuleBase class item. I know I can just pass the ModuleID to the class at the time I call it, but I would like to know how to get the ModuleID directly, similar to how one can retrieve the PortalID by calling PortalController.GetCurrentPortalSettings().PortalID


Ben Santiago, MCP Certified & A+ Certified
Programmer Analyst
(SQL, FoxPro, VB, VB.Net, Java, HTML, ASP, JSP, VBS, Cognos ReportNet)
 
New Post
3/26/2012 9:48 AM
Accepted Answer 

It's easiest to simply pass it as a parameter to the custom class.

Other possibilities may be to pick it off from the Request.QueryString (usually the "mid" parameter) if your module has redirected to another module control; from an object which you have cached and which exposes a previously set ModuleID property; and by various lookups by the module definition's name if you are certain that yours is the one and only module of its type on the active tab or anywhere on the site.


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
3/29/2012 8:12 AM
 

William,

Thank for the response.  I did as you suggested.  I could not find any other way other than passing it as a parameter to my class.


Ben Santiago, MCP Certified & A+ Certified
Programmer Analyst
(SQL, FoxPro, VB, VB.Net, Java, HTML, ASP, JSP, VBS, Cognos ReportNet)
 
New Post
10/4/2012 12:42 PM
 
PortalModuleBase.ModuleID property.

Regards rypki
 
New Post
1/22/2016 2:39 PM
 
I know this is an old thread, but I just recently came across this issue again. Previously I was programming for DNN 6.x, now I am programming for DNN 7.x. I was hoping things changed but they haven't.

Just so there is no confusion for anyone else that comes across this, the suggestion from Bartosz Siemasz is wrong. The only method available for this situation is to pass the ModuleID to the custom class. There is no method available within a class to automatically retrieve the current ModuleID.

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 ExtensionsModulesModulesHow To Get ModuleID?How To Get ModuleID?


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