Published: 17 Jan 2007
By: Oleg Zhukov

This article explains how to make changes to DotNetNuke modules varying their look-and-feel as well as adding some fundamental behavior.


DotNetNuke is shipped with a number of feature-rich modules suitable for various tasks. However a necessity to modify a module’s behavior may arise. This article covers how to easily modify DNN modules and extend their behavior. To understand the article easily I recommend that you download the article code.

As a case in point, we will make minor modifications to the Blog module step by step But first let us clarify DotNetNuke's basic structure.

DotNetNuke module structure

In DNN 4.x a module is usually comprised of front-end controls (in *.ascx files) and module’s logic (*.dll assemblies). A module’s front-end is located under DesktopModules\<Module_Name>\ folder. The assemblies files can be found in Bin\ folder.

Due to the need of an entire recompilation, modifying a module’s *.dll file is a complicated task. So we will insert all additional behavior into *.ascx files and will deal with them through the rest of the article.

Step 1: Removing needless parts

Some information displayed in a module may be redundant and should better be hidden. For example the calendar in a blog archive view is needless if posts aren’t made often. The below code will remove the calendar from the Blog archive.

Take a look at the contents of Archive.ascx file (in the DesktopModules\Blog folder). It describes how the archive view looks. Several lines in the beginning of the file contain definitions for unwanted items:

However we cannot simply remove label and calendar controls since they are referred to in the underlying dll’s. Instead we should set their visible attribute to false:

This will make a module contain only what is desired and nothing more.

Step 2: Rearranging existing controls

Let us now draw attention to the search box of the Blog module. Say we want the dropdown at the top to be hidden and the radio buttons to be arranged vertically.

Here we need to modify the Search.ascx file. Hiding the dropdown is the same as in Step 1. Arranging the radio buttons vertically is not harder we just set repeatdirection property of the radiobuttonlist control to Vertical

Please note that changes to the visual style of a module (e.g. fonts, colors, etc.) are made through module.css style sheet.

Step 3: Adding logic to a module

So far we have dealt only with visual modifications to modules. But what if it’s necessary to add some new functionality to a module? We will add the total number of posts in a given month to the Blog Module. While I would highly recommend that you do this through the code files, we’ll actually do it via the ascx control.

For example let us make blog archive show the number of posts for each month.

In order to get the number of posts made in a particular month a SQL query should be executed. Since inline querying is forbidden in DotNetNuke we need to create an appropriate Storedprocedure which will return the desired count.

A stored procedure can be created by the means of the DotNetNuke SQL tool. Open it with Host > SQL menu item. Then paste the Storedprocedure creation query, select Run as Script and click Execute.

The storedprocedure to retrieve the number of posts for a specific month can be downloaded with the sources for the example.

Creating the storedprocedure is not the only thing we need do. In order to execute it we need to provide the proper connection settings and procedure parameters. Connection settings can be retrieved by static methods of the corresponding DataProvider subclass. Other parameters depend on the specific case, for example portal ID can be obtained via PortalId property of a module’s front-end control.

Anyway we will need to embed server scripts with additional logic into *.ascx controls. Here is how it would look for our example:

The storedprocedure used is Blog_GetEntriesCountForMonth and it is called with the SqlHelper.ExecuteReader static method. Here we use standard ASP.NET notation <%#expression%> to embed calculated values into the markup.


DotNetNuke is an open-source framework making it possible to modify the behavior of all of its parts including native and new modules. Throughout this article we have addressed questions of making changes to modules by modifying their *.ascx front-end files. Such changes do not require recompilation of underlying dll’s though they may contradict standard the DotNetNuke programming model. Anyway if a minor change to a module should be made then modifying module’s *.ascx files is the easiest way to.


The example improvements to the Blog module can be found in the downloads section of my website. Or just click here for direct access.


Improved Blog

Continue reading and see our next or previous articles Next Article >>

About Oleg Zhukov

Oleg Zhukov, born and living in Russia is Lead Engineer and Project Manager in a company which provides business software solutions. He has graduated from Moscow Institute of Physics and Technology (MIPT) (department of system programming) and has got a M.S. degree in applied physics and mathematics...

This author has published 5 articles on DotNetSlackers. View other articles or the complete profile here.

Other articles in this category

Reverse engineering DotNetNuke skin
This article shows how to extract skin from a DotNetNuke-based portal.

You might also be interested in the following related blog posts

Issue 50 - DotNetNuke 5 Admin Modules Access, Reset Logins, iPhone OWS read more
How to Limit Access to Administrator Modules in DotNetNuke 5 - 5 Videos read more
How to Create an iPhone App with OWS - 4 Videos read more
Performance Gains and Enhanced HTML-like Support Brought to WinForms Applications with Q3 2009 Release read more
Beta Testers Wanted: DotNetNuke 5.2.0 Beta Now Available read more
DotNetNuke 5.1.4 Released read more
DotNetNuke 5.1.3 Released read more
DotNetNuke 5 Quick Start Guide - 6 Free Videos read more
How to Install a Module in DotNetNuke 5 - Free Video read more
Issue 48 - DotNetNuke 5 Introduction and Open Web Studio Tutorials read more


Subject Author Date
placeholder Would love to get this to work... John Helfen 5/28/2008 11:09 AM
How to make it work for Blog Module ver. 03.04.00 Oleg Zhukov 6/20/2008 7:47 AM
placeholder How to make it work for Blog Module ver. 03.04.00 Oleg Zhukov 6/20/2008 7:49 AM
That did it! John Helfen 6/20/2008 10:36 PM

Please login to rate or to leave a comment.