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.0Accessing PortalId, UserId, ModuleId from non-page/module classAccessing PortalId, UserId, ModuleId from non-page/module class
Previous
 
Next
New Post
3/6/2008 5:39 PM
 

How can I access the PortalId, UserId and ModuleId from a vb class that is a component of a module i'm using? The class extends gridview columns, but i need it to know the above information.

 
New Post
3/6/2008 9:49 PM
 

The one that you will have to pass into the component is ModuleId. For the others plus a few you didn't mention, you can (in most cases) get as follows thanks to a few shared methods and current UserInfo and PortalSettings objects that are passed on the HttpContext:

Dim _PortalSettings As DotNetNuke.Entities.Portals.PortalSettings = _
             DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings

Dim _PortalId As Integer = _PortalSettings.PortalId

Dim _UserID As Integer = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo.UserID

Dim _TabID As Integer = _PortalSettings.ActiveTab.TabID

Dim mc As New DotNetNuke.Entities.Modules.ModuleController
Dim _ModuleConfiguration As DotNetNuke.Entities.Modules.ModuleInfo = mc.GetModule(_ModuleId, _TabID)
Dim _TabModuleID As Integer = _ModuleConfiguration.TabModuleID

Dim _Settings As HashTable = DotNetNuke.Portals.PortalSettings.GetTabModuleSettings(_
                                  New Hashtable(mc.GetModuleSettings(_ModuleId)), _
                                  New Hashtable(mc.GetTabModuleSettings(_TabModuleID)))

If my module has lots of settings I prefer to define a class to encapsulate each setting with a strongly typed property and then store this class object onto the cache (keyed by ModuleId or TabModuleID as appropriate). It is then very easy to load this class object from the cache in your component.  Since many components will need the availability of all of the above information, I have defined a base component class that obtains each value as readonly properties and then inherit each component class from it when needed.


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
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Accessing PortalId, UserId, ModuleId from non-page/module classAccessing PortalId, UserId, ModuleId from non-page/module class


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