Home > Uncategorized > Creating a DNN Module with View and Edit Controls

Creating a DNN Module with View and Edit Controls

Today I’m creating a custom module for a DotNetNuke site I’m building. I use DNN to gain access to many of it’s Content Management and Security features, but also for the ease of integration by which I can add custom modules I’ve completely designed on my own. Today I want to create a module that integrates directly into the DNN admin features, so I’d like to create a VIEW and an EDIT control so that I can manage data and settings for my module.

To start, I simply create two User Controls in a subfolder I’ve created within the DesktopModules folder like so:

Edit.ascx will be the file used to edit settings and data displayed by View.ascx.

Before I go into the DNN site itself and create this module, I want to set up the correct inheritance for these controls, so I go to the .VB file for each and change the Inherits line:

  • Edit.ascx:


Inherits DotNetNuke.Entities.Modules.ModuleSettingsBase




  • View.ascx


Inherits DotNetNuke.Entities.Modules.PortalModuleBase




Setting up these inheritance properties will allow them to be used correctly within the DNN site and gain access to built-in functionality such as ModuleID, TabId, and Module Settings.

Once that is done, I am ready to create a module definition. To do that, I log into the DNN site under the host account and go to Host / Module Definitions. From there, I select the drop down next to Module Definitions and choose Create Module Definition.

I’m going to create a module definition starting from the view.ascx control, so I choose… you guessed it… Create from Control.

From the next page, I enter the values I need for the initial view (the view mode) of the module:

Once my module is created, I need to add Edit functionality to it. To do that, I click the pencil next to the newly created module definition:

From here, I need to add a new Module Control for the settings section of the control. I click Add Module Control under Module Controls.

Now, I carefully enter the data for my settings / edit control:

Things that are critical here: “Key” must be equal to “Settings” (I think, maybe not). I do know that “Type” must be equal to “EDIT”.

That’s really the extent of it. If I go back to my View.ascx and Edit.ascx file and enter a little sample HTML, I can then verify that my pages are appearing correctly.

Here’s the content of view.ascx

Language=”VB” AutoEventWireup=”false” CodeFile=”View.ascx.vb” Inherits=”DesktopModules_C2IT_Map_View”


Here's the map you want to see.</p>



And here’s the content of edit.ascx

Language=”VB” AutoEventWireup=”false” CodeFile=”Edit.ascx.vb” Inherits=”DesktopModules_C2IT_Map_Edit”


Here's where you edit the settings for your map.</p>



When I add this module to a page, I expect to see the contents of view.ascx in the Pane I add it to, and that’s exactly what I see:

If I click the Pencil or go to Settings in the dropdown menu, I see the settings module right where I expect it, down below the Page Settings section I’m used to:

From this point, I can do whatever I want to in my controls. In this case, I’ll be using view.ascx to display data from a database. Edit.ascx will simply have a DataGrid that allows you to edit that data.

I could also use ModuleSettings to get / set parameters for the module, which I’ve done before.

To retrieve settings, I just need to IMPORT DotNetNuke.Entities.Modules and then I can get settings using ModuleSettings(“SettingName”)

To store settings, I need to first create a new ModuleController and then store the value to be saved in the UpdateSettings sub, like this.

Sub UpdateSettings()



Dim mc As

mc.UpdateModuleSetting(ModuleId, “Filter”, ddlFilter.SelectedValue)

mc.UpdateModuleSetting(ModuleId, “ColumnCount”, txtColumns.Text)






That’s really all there is to it. You can do much more with these, but this is a common starting point to creating a simple VIEW and EDIT module pair in DotNetNuke.

Need help? Give us a call at (317) 721-2248 or email chetcromer@c2itconsulting.net; this is what we do all day, every day… well not really ALL day, and not really EVERY day, but it’s something we’ve done many times and would be glad to help you with.


Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: