Module Settings and Personalization: Easily Store Data For Your DotNetNukeŽ Module (in VB and C#)

Nearly half of your module development can be spent creating database objects (tables and stored procedures) and data access methods. You can leverage the DotNetNuke framework and reduce or eliminate this task.

What Module Settings Will Do For You

Module Settings will allow you to easily store data that is specific to an instance of a module. A DotNetNuke module can be placed on multiple pages in a portal (even on the same page). Each time is a separate instance.

Module Settings is usually used to store the data for the Settings user control of a module, but it can be used on any of the module's user controls.

What Personalization Will Do For You

Personalization will store data that is specific to a single user. With the DotNetNuke Survey module, personalization is used to determine if an authenticated user has voted before. If they have they are only showed the results and not allowed to vote again.

Implementing Module Settings

We used this code to save data to the Module Settings:


Dim objModules As New DotNetNuke.Entities.Modules.ModuleController
objModules.UpdateModuleSetting(ModuleId, "surveyclosingdate"
, DotNetNuke.Common.Globals.DateToString(datClosingDate))


DotNetNuke.Entities.Modules.ModuleController objModules = new DotNetNuke.Entities.Modules.ModuleController();
objModules.UpdateModuleSetting(ModuleId, "surveyclosingdate", DotNetNuke.Common.Globals.DateToString(datClosingDate));

We retrieve the data using this code:


txtClosingDate.Text = CType(Settings("surveyclosingdate"), Date).ToShortDateString


txtClosingDate.Text = Convert.ToDateTime(Settings["surveyclosingdate"]).ToShortDateString();

Implementing Personalization

To implement Personalization  this code is used:


DotNetNuke.Services.Personalization.Personalization.SetProfile(ModuleId.ToString, "Voted", True)


DotNetNuke.Services.Personalization.Personalization.SetProfile(ModuleId.ToString(), "Voted", true);

We retrieve the Personalization setting using this code:


' Check if the user has voted before
If Not DotNetNuke.Services.Personalization.Personalization.GetProfile(ModuleId.ToString, "Voted") Is Nothing Then
CType(DotNetNuke.Services.Personalization.Personalization.GetProfile(ModuleId.ToString, "Voted"), Boolean)


// Check if the user has voted before
if (!(DotNetNuke.Services.Personalization.Personalization.GetProfile(ModuleId.ToString(), "Voted") == null))
  return ((bool)(DotNetNuke.Services.Personalization.Personalization.GetProfile(ModuleId.ToString(), "Voted")));
  return false;

Leverage The DotNetNuke framework

Generally you will want to create tables and stored procedures and data access methods so that you can optimize performance. However, many situations may exist where minimal amounts of data are needed and development time can be reduced by leveraging the DotNetNuke framework.

[Back to: The ADefWebserver DotNetNuke HELP WebSite]

DotNetNukeŽ is a registered trademark of Perpetual Motion Interactive Systems Inc.