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.0Running code when a module is added to containerRunning code when a module is added to container
Previous
 
Next
New Post
9/16/2008 2:22 PM
 

I would like to run some code that looks to see if a custom user profile exists and if not, creates it.  I have the code to do this, however, I want to run this code every time the module is added to a container.  This way, it will only add the user profile to the current portal id. 

Is there an event I can trap that fires when a module is added to a container?  Thanks!

 
New Post
9/17/2008 2:35 AM
 

MM i wouldnt know about that but here is somethign i have done in the past.

Make a skinobject and add that in your container, when the container is added to your module that skinobject is run and you can do all your code in there. Just make sure you dont run it every time the container is loaded but check if the user is allready in the profile dont do aything alse run the code

 

 

 
New Post
9/17/2008 8:48 AM
 

I assume that when you say "run code everytime the module is added to a container", you mean when the module is added to a page by using the "Add New Module" commands in the control panel.

If so, the best way to check if this is a new instance of the module is to check (usually in the Page_Load handler of the view control) with the following code:

If Me.Settings.Count = 0 Then
  'Run code to check if profile exists and create if necessary
  'Pre-configure module settings with at least one setting so that this code will not run next time.
End If

In the unlikely case that your module will not be adding at least one setting key/value to the ModuleSettings table, you will need to set one as follows:

Dim mc As New Entities.Modules.ModuleController()
mc.UpdateModuleSetting(Me.ModuleId, "Initialized", "True")

I generally create a class for the module's configuration, returning each setting as a strongly typed property and providing for loading and saving the configuration from/to ModuleSettings or TabModuleSettings as appropriate. In most cases, I include code such as the above to determine if the module has been initialized to both pre-configure the settings to default values and to run once any custom code.

 


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
9/17/2008 10:07 PM
 

Nice!  A clever solution I never would have thought of.  Thanks!

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Running code when a module is added to containerRunning code when a module is added to container


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