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 { get { ModuleActionCollection Actions = new ModuleActionCollection(); Actions.Add(this.GetNextActionID(), Localization.GetString(ModuleActionType.AddContent, this.LocalResourceFile), 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
- 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:
Songbird Essentials Nest View Bird HouseFeatures: Assembled window view birdhouse. Made in America from long lasting cedar. Suction cups attach to window. What a great educational idea for children and adults alike.
WWE Wrestling PPV Pay Per View Series 20 Action Figure Jeff HardyThe leader of the future of TNA is featured here in this beautiful WWE Wrestling PPV Pay Per View Series 20 Action Figure Jeff Hardy.. Jeff Hardy's face is painted White!! Very hard to find figure.. Brand new and never opened!!











[...] we took a look at the Anatomy of the View component and touched on the ModuleActions property. Today, we are going to dig into the Actions.Add() [...]
[...] Anatomy of a View [...]