Introduction
The DotNetNuke portal framework allows developers to create custom modules to
extend the functionality provided by the base portal installation. The
framework allows the developer to define a single desktop control and a single
edit control. This limitation has led developers to create elaborate
controls which consist of multiple panels. As the user navigates to
different states within the module, different panels are displayed or hidden.
This approach makes module maintenance very difficult and mixes the programming
logic from different functional areas of the module.
In order to separate functionality and ease module development and
maintenance, I developed a Multi-Page framework that utilizes a concept similar
to the way DNN dynamically injects modules into a content pane on a tab.
By using a single "dispatch" control and passing in a page identifier, the
developer is free to create elaborate modules with as many pages as required to
meet the module requirements.
Define a Dispatch PortalModuleControl
The first step is to create a new "module". This module will have
a dispatcher for the desktop functionality and a dispatcher for the edit
functionality. Both dispatcher controls follow the same design. So
lets look at the Dispatcher code: The first half of the Page_Load event
identifies the module page to be loaded. The second half of this event
loads the appropriate PortalModuleControl, sets the ModuleConfiguration
information and adds it to the dispatcher control collection.
Public Class Dispatch
Inherits PortalModuleControl
Dim _DefaultPage As String = "~/DeskTopModules/MultiPageModule/Page1.ascx"
Private Sub Page_Load(ByVal sender As System.Object, ByVal e_
As System.EventArgs) Handles MyBase.Load
If Not (Request.Params("PageID") Is Nothing) Then
Dim ForumPage As Integer = CInt(Request.Params("PageID"))
Select Case ForumPage
Case Utility.MultipageDesktopType.Page1
_DefaultPage = "~/DeskTopModules/MultiPageModule/Page1.ascx"
Case Utility.MultipageDesktopType.Page2
_DefaultPage = "~/DeskTopModules/MultiPageModule/Page2.ascx"
End Select
End If
' This code adds the appropriate control to the
' dispatcher's child control collection
Dim objModule As PortalModuleControl = CType(CType(Me.Page, _
BasePage).LoadModule(_DefaultPage), PortalModuleControl)
If Not objModule Is Nothing Then
objModule.ModuleConfiguration = Me.ModuleConfiguration
Controls.Add(objModule)
End If
End Sub
Private Sub cmdPage1_Click(ByVal sender As Object, ByVal e_
As System.EventArgs) Handles cmdPage1.Click
Response.Redirect(Utility.BuildDesktopLink(Me.TabId, _
Utility.MultipageDesktopType.Page1), True)
End Sub
Private Sub cmdPage2_Click(ByVal sender As Object, ByVal e_
As System.EventArgs) Handles cmdPage2.Click
Response.Redirect(Utility.BuildDesktopLink(Me.TabId, _
Utility.MultipageDesktopType.Page2), True)
End Sub
End Class
The dispatcher ascx file is very simple. It contains the ModuleTitle
control that is displayed for all desktop pages. The edit screen
dispatcher has a separate ModuleTitle.
<%@ Register TagPrefix="Portal" TagName="Title"
Src="~/controls/DesktopModuleTitle.ascx"%>
<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="Dispatch.ascx.vb" Inherits="MultiPageModule.Dispatch" %>
<portal:title id="Title1" EditText="Edit Screens" runat="server">
</portal:title><BR>
See the attached code for a fully working module which demonstrates this
concept.
Written by Joe Brinkman, Joe can be reached via email at
joe.brinkman@TAG-Software.net
or visit his Website at
http://www.tag-software.net.