After reviewing the way Scott McCulloch did the NewsArticles, I was
able to recreate the handling of multiple view controls. It is quite
simple really.
1. Create a default holding control (primary view control for the
module). This control will be used for all of the switching of view
controls. It has only one server control on it:
<code>
<asp:PlaceHolder id="plhControls" runat="Server" />
</code>
2. Send a querysting variable to the tab to specify which view
control to load. Use the following code to reference the desired
control:
<code>
Private m_controlToLoad As String
Private Sub ReadQueryString()
If Not (Request("ControlType") Is Nothing) Then
Select Case Request("ControlType").ToLower()
Case "sales"
m_controlToLoad = "SalesSummary.ascx"
Case "orders"
m_controlToLoad = "OrdersSummary.ascx"
Case Else
m_controlToLoad = "SalesSummary.ascx"
End Select
Else
m_controlToLoad = "SalesSummary.ascx"
End If
End Sub
</code>
3. Load the control through code, as follows:
<code>
Private Sub LoadControlType()
Dim objPortalModuleBase As PortalModuleBase = CType(Me.LoadControl(m_controlToLoad), PortalModuleBase)
If Not (objPortalModuleBase Is Nothing) Then
objPortalModuleBase.ModuleConfiguration = Me.ModuleConfiguration
objPortalModuleBase.ID =
System.IO.Path.GetFileNameWithoutExtension(m_controlToLoad)
plhControls.Controls.Add(objPortalModuleBase)
End If
End Sub
</code>
4. Fire these two routines each time the page initializes:
<code>
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
ReadQueryString()
LoadControlType()
End Sub
</code>
5. In order to switch to another control, place this code in the desired event:
<code>
Response.Redirect(NavigateURL() + "&ControlType=orders")
</code>
Ahhh...now I have freedom to add as many view controls within a
module as I need. Scott, thank you very much for pointing out the way.
Vielen Dank!!
Ling