Home » DotNetNuke - Module Development » DotNetNuke Modules – Anatomy of the View

DotNetNuke Modules – Anatomy of the View

Now that we’ve laid the foundation of DotNetNuke modules, it is time to start looking at the specific modules. While it would be practically impossible to cover every detail and every API feature of a DotNetNuke component, we do want to look closely enough that you know what you are looking at as you are trying to write your code.

Open up Visual Studio and open the code behind for the view module we created. If you are following along, this would be the ViewDMBSample.ascx.cs file.

Starting from the top, you’ll notice that the class has been wrapped in a name space. You’ll want to change “YourCompany” to something unique to your company. If you have a domain, you might decide to use that. I use “dmbcllc” for mine.

The second item you’ll notice is that the class ViewDMBSample inherits from PortalModuleBase and IActionable instead of System.Web.UI.UserControl. PortalModuleBase inherits from System.Web.UI.UserControl, so you haven’t lost anything, DotNetNuke has just inserted some additional functionality between System.Web.UI.UserControl and the code we will be writing. It is PortalModuleBase that gives us access to things like the ModuleId and PortalId properties that we will need to do our module development.

That all makes sense, you say, but what about that IActionable thing?

IActionable tells DotNetNuke that this control implements the ModuleActions property that you will find in the “Optional Interfaces” code region. ModuleActions returns a collection of type ModuleActionCollection and each element in that collection adds an additional action to the module’s action menu.

The property looks like this right after you’ve run the template wizard:

public ModuleActionCollection ModuleActions
        ModuleActionCollection Actions = new ModuleActionCollection();
            ModuleActionType.AddContent, "", "",
            this.EditUrl(), false,
            SecurityAccessLevel.Edit, true, false);
        return Actions;

But by simply adding another Actions.Add() statement, you can add another menu option that will load another ASCX file that has been registered with DotNetNuke. The details on how we would do that, exactly, are the topic of our next lesson.

Finally, we want to take a quick look at the Page_Load() method where we commented out most of the functionality. The one thing that I want to point out today is the catch block at the bottom:

catch (Exception exc) //Module failed to load
    Exceptions.ProcessModuleLoadException(this, exc);

You want all of your catch blocks to look similar. ProcessModuleLoadException() logs the error into the event log so that you can see the error even if you weren’t running the application at the time the error occured. This is a HUGE benefit to tracking down errors that your customers report.


    Other post in DotNetNuke - Module Development

    Like this Article? Subscribe to get every article sent to your email.

    Related Post

    • DotNetNuke Modules – Creating Base ModulesDotNetNuke Modules – Creating Base Modules Now that we have DotNetNuke installed into Visual Studio we can go ahead and create our first modules. Actually, creating the modules is pretty simple. But it is even easier to do it […]
    • DotNetNuke 5.x Can’t Move Module On A PageDotNetNuke 5.x Can’t Move Module On A Page As I mentioned a couple of days ago, the move to DotNetNuke 5 has brought about a few changes.  Some of them are design decisions that are just frustrating, like not being able to […]
    • DotNetNuke Modules – Exceptions the DNN WayDotNetNuke Modules – Exceptions the DNN Way Everyone knows (or should know) that handling exceptions is  a fundamental feature of the .NET environment.  And most of the time if we don't handle the exception ourselves the .NET […]
    • DotNetNuke Modules – PortalModuleBaseDotNetNuke Modules – PortalModuleBase We've been through most of the basics now with respect to creating the View module of the DotNetNuke module set.  We will be moving on to the Settings module next.  But before we do, we […]
    • DotNetNuke Modules – Foundational ConceptsDotNetNuke Modules – Foundational Concepts There are two design patterns that DotNetNuke relies on heavily, not just in the core code, but in any module you might develop.The first is a three tiered architecture, or more […]

    About Dave Bush

    Dave Bush is a Full Stack ASP.NET developer. His commitment to quality through test driven development, vast knowledge of C#, HTML, CSS and JavaScript as well as his ability to mentor younger programmers and his passion for Agile/Scrum as defined by the Agile Manifesto and the Scrum Alliance will certainly be an asset to your organization.

    2 Pingbacks/Trackbacks