DotNetNuke Modules – Module Settings
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
objModules.UpdateTabModuleSetting
(TabModuleId, "key", "Value");
or
objModules.UpdateModuleSetting
(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.
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
- Creating DotNetNuke Modules - May 20th, 2008
- Creating DNN Modules - The Tools - May 22nd, 2008
- DotNetNuke Modules - Foundational Concepts - May 26th, 2008
- DotNetNuke Modules - Install DNN into VS 2008 - May 27th, 2008
- DotNetNuke Modules - Creating Base Modules - May 28th, 2008
- DotNetNuke Modules - Registering Your Module - May 29th, 2008
- DotNetNuke Modules - Where Stuff Shows Up - June 3rd, 2008
- DotNetNuke Modules - Benefits of Architecture - June 4th, 2008
- DotNetNuke Modules - Anatomy of the View - June 9th, 2008
- DotNetNuke Modules - Adding Actions - June 11th, 2008
- DotNetNuke Modules - DNN Controls - Label - June 18th, 2008
- DotNetNuke - Internationalization - June 25th, 2008
- DotNetNuke Modules - Internationalization (part 2) - June 30th, 2008
- DotNetNuke Modules - Labels w/ no Help - July 9th, 2008
- DotNetNuke Modules - LinkButtons - July 14th, 2008
- DotNetNuke Modules - Collapsible Panels - July 16th, 2008
- DotNetNuke - The Data Layer - Installing CodeSmith - July 22nd, 2008
- DotNetNuke - Modules - Creating The Tables - July 24th, 2008
- DotNetNuke - Modules - Creating Stored Procs - July 29th, 2008
- DotNetNuke - Modules - Portal Specific Modules - July 31st, 2008
- DotNetNuke Modules - Data Access Layer - August 5th, 2008
- DotNetNuke Modules - Data Access Layer - August 7th, 2008
- DotNetNuke - Data Access Layer Alternative - August 12th, 2008
- DotNetNuke - Modules - Linking within the module - August 14th, 2008
- DotNetNuke - Make Your Module Searchable - August 19th, 2008
- DotNetNuke Modules - Making Content Portable - August 25th, 2008
- DotNetNuke Modules - Exceptions the DNN Way - September 2nd, 2008
- DotNetNuke Modules - PortalModuleBase - September 4th, 2008
- DotNetNuke Modules - Inter Module Communication - September 9th, 2008
- DotNetNuke Modules - Finding The Page a Module is On - September 15th, 2008
- DotNetNuke Modules - Caching - September 17th, 2008
- DotNetNuke Modules - Module Settings - September 22nd, 2008
- DotNetNuke Modules - Retrieving Settings - September 24th, 2008
- DotNetNuke Modules - Advanced Architecture - October 20th, 2008
- DotNetNuke Modules - Creating the PA - October 30th, 2008
- DotNetNuke Modules - Automating the PA - November 5th, 2008
- DotNetNuke - FileUploadControl Danger! - February 26th, 2009
- DotNetNuke SecurityException AspnetHostingPermission - October 14th, 2009
- Changing an Existing DNN Module - March 4th, 2010
Other Related Items:
Micro Set Setting Solution, 1 ozMicro Set Setting Solution 1oz
Noctua NF-S12B FLX 120 mm 3 Speed Setting Beveled Blade Tips Design SSO Bearing Fan SCD 2 - RetailNoctua NF-S12B FLX, 120mm, 3 Speed Setting, Beveled Blade Tips Design, SCD 2, SSO Bearing Fan_ Retail . Spec. Type : Fan Fan Size : 120 x 120 x25mm Co... Read More >
Professional DotNetNuke 5: Open Source Web Application Framework for ASP.NET (Wrox Programmer to Programmer)DotNetNuke creator Shaun Walker leads this superlative author team of MVPs while delivering the latest update of a bestseller. They offer complete cov... Read More >









