DotNetNuke Modules – Module Settings

ppl-body-02 Since each instance of a module that we put on a page should be able to have it’s own configuration information, it is necessary to have some place that will allow us to configure it.

For example, you may have a module which could display itself in a number of different ways.  You need some way to set this and the settings ASCX file and the associated codebehind file is the place to do this.


When we first created our sample module, an associated settings file was created along with it.  You’ll want to open that up now.

< vent Wireup
The settings module is just another user control that shows up in the settings page.  What makes it a little different is that it has two events that fire to tell the module to load and save the settings.

The reason for this is that the save button (it’s actually a link) is not a part of this module.  So if you were relying on the save link to fire and save the contents of this form, you’d either confuse the user by having two save mechanisms on the settings page, or you’d never see the event.

The other thing that’s a little odd is that the information on this page is not typically saved to tables specific to the module.  Instead they are saved into the DotNetNuke settings table.  But you don’t need to worry about that because you’ll be using DotNetNuke-supplied APIs.

When the settings module was created, it should have created two methods:

n style="color: blue;">public override void LoadSettings()


public override void UpdateSettings()

We will start our work with UpdateSettings() since we have to save data before it makes any sense to retrieve it.

There are two separate API calls for save settings data.  Each looks very similar to the other, but they each do distinctly different things.

< aving Data
For each of these calls, you will need to create an instance of the ModuleController object, so we should make that the first line in our UpdateSettings method:

DotNetNuke.Entities.Modules.ModuleController objModules =
    new DotNetNuke.Entities.Modules.ModuleController();

Once we have that we call either

    (TabModuleId, "key", "Value");


    (ModuleId, "key", "value");

UpdateModuleSetting() saves configuration information that is common to every instance of the module regardless of what page it shows up on and how many are currently on the page.  Think of it as global settings for this module wherever it shows up.

UpdateTabModuleSetting() saves configuration information that is specific to this module on this page, and if there are multiple instances of the module on the page, this is specific to the specific module on the page.

The first parameter is either the TabModuleId or the ModuleId which are both properties of the settings module and the view module.  So you can just put them in as shown above.

The second parameter is a key value that we will use to look up this information later.  I’ve found that it works best to use the ID of the control on the ASCX file that I’m using to collect the information that I’m saving with these modules as the key.  This makes it easy to correlate the two when you are maintaining the code later.

ything is a String
The value you save is always a string representation of the data that needs to be saved.  So if you need to save a number or a boolean value, you’ll want to convert it to a string using ToString() first.  Keep in mind that when you retrieve the information, you’ll need to convert it back to a number or a boolean.

That’s really all there is to it.  Once you understand what those two methods do, the actual implementation is pretty easy.

On Wednesday, we’ll take a look at the other side of this: Retrieving the information.


Other post in DotNetNuke - Module Development

Related Post

Leave a Reply

Comment Policy:

  • You must verify your comment by responding to the automated email that is sent to your email address. Unverified comments will never show.Leave a good comment that adds to the conversation and I'll leave your link in.
  • Leave me pure spam and I'll delete it.
  • Leave a general comment and I'll remove the link but keep the comment.

Notify me of followup comments via e-mail