Wednesday, October 29, 2008 2:14 PM bdukes

Get Module by Module ID in DotNetNuke

When building DotNetNuke modules, a number of times I've run up against the issue of trying to instantiate a ModuleInfo instance with only a module ID.  However, the GetModule signature on ModuleController takes both a module ID and a tab ID.  In this latest instance where I've come against this issue, I was actually trying to get a tab ID based on the module ID, so I obviously didn't already have one to provide. 

As I started to move down the road of writing my own query to get this simple thing done, I found that the GetModule method and underlying query will take a "null" value for the tab ID!  Unbeknownst to me, the solution was right in front of me, right where I expected it to be the whole time, I just couldn't see it.

So, if you need a ModuleInfo instance and you only have a module ID, call GetModule(moduleId, Null.NullInteger) and you're good to go!

(I've put in a request with the people in charge to add an overload to GetModule so that this is more obvious going forward)

Filed under: , , , , , , , , , ,

Comments

# Get Module by ModuleId - Brian Dukes, Web Developer

Wednesday, October 29, 2008 4:31 PM by Get Module by ModuleId - Brian Dukes, Web Developer

Pingback from  Get Module by ModuleId - Brian Dukes, Web Developer

# re: Get Module by Module ID in DotNetNuke

Wednesday, October 29, 2008 5:34 PM by icecold_2

I've ran into this in many of the methods and wouldn't find out until I found an example using the "NULL" in the DNN source. VERY ANNOYING!

Hopefully you can get them to change it, or have an alternative method that takes a nullable param, or leave the param off.

# re: Get Module by Module ID in DotNetNuke

Thursday, October 30, 2008 3:34 PM by Will Strohl

Nice find!  Thanks for sharing, and submitting to Gemini.

# HOW TO: Get Module By ModuleID (without the TabID) in DotNetNuke

Thursday, October 30, 2008 3:46 PM by The Mighty Blog

I just ran across a blog entry from someone that described how to do this. ...

# re: Get Module by Module ID in DotNetNuke

Tuesday, November 11, 2008 5:05 AM by Jen

Helpfull blog...

# re: Get Module by Module ID in DotNetNuke

Thursday, March 12, 2009 2:02 AM by KiT

That's great!  Thanks for the info.  You've saved my day :D

# re: Get Module by Module ID in DotNetNuke

Saturday, May 09, 2009 1:45 PM by www.almny.com

how i know module id

becuase i create new module but i cann't excut it

# re: Get Module by Module ID in DotNetNuke

Thursday, September 03, 2009 11:44 AM by J

Hi guys...

In  a page put 2  same modules and every time a module is  loaded in the page i want to create a directory based on the moduleId...  can anybody help me out

thanks

j

# re: Get Module by Module ID in DotNetNuke

Thursday, September 03, 2009 12:07 PM by bdukes

J,

I'm not really sure of what you're asking.  If you could post some more details about what you're wanting, maybe someone on the DotNetNuke forums will be able to help you.

Hope that helps,

Brian Dukes

# re: Get Module by Module ID in DotNetNuke

Thursday, September 03, 2009 12:20 PM by J

OK   I have a Polls Module.   I want to Embed that One  on a page.

As soon as i embed that on the page... An Automatic script should run which should create a folder in DesktopModules with a name "Feed+Moduleid"

for example Module id is 380   then the name of the folder should be feed380

thanks

J

# re: Get Module by Module ID in DotNetNuke

Thursday, September 03, 2009 12:38 PM by bdukes

Assuming that you own that module, you could place some code in the main control of that module to check if the folder already exists, and create it if not.

Other than that, I don't know of any generic way to run code when a module is placed on the page.  What are you trying to accomplish by creating these folders?

# re: Get Module by Module ID in DotNetNuke

Monday, October 19, 2009 8:09 AM by Mazen

Hi,

I'm trying to add settings for my module after checking if it's already available or not (to update if it's available). But when i call ModuleId for the second time (to add the new settings), the ModuleId becomes null!!! how can i make the ModuleId persistent in my module?

thank you.

Leave a Comment

(required) 
(required) 
(optional)
(required)