Getting NavigateURL() to Work
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:
=asp:PlaceHolder id="plhControls" runat="Server" /=
2. Send a querysting variable to the tab to specify which view control to load. Use the following code to reference the desired control:
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
3. Load the control through code, as follows:
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
4. Fire these two routines each time the page initializes:
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
5. In order to switch to another control, place this code in the desired event:
Response.Redirect(NavigateURL() + "&ControlType=orders")