This is a migrated thread and some comments may be shown as answers.

How can I pass querystring values to page loaded in PageView

1 Answer 58 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 17 Nov 2013, 10:59 PM
I used the example for the  Dynamic Tabs with Multipage project to create a tabstrip with multipages that load a scheduler on each tab. The Multipage creates the pageview on demand when the user clicks on the tab. If the tab page is already created, it shows it.

I need to pass some values in the URL to be picked up in the page. But, I can't figure out how to do it with the pageview. The pageview loads the page name into a control that is added to the pageview controls collection. If I attempt to include the parameters in the URL like this, "Appointments.ascx?S=123", it throws an error.

How can I handle this?

1 Answer, 1 is accepted

Sort by
0
Steve
Top achievements
Rank 1
answered on 18 Nov 2013, 12:45 AM
I got it working by implementing an interface on the control as follows, for anyone else that may need to do this.

in the ascx, add an interface at the end of the control class, like this.

Public Interface ICustomParams
    Property StoreID() As String
    Property CustomerID() As String
End Interface


In the ascx, add the implements statement like this, along with the properties implemented.


Public Class AppointmentDisplay
    Inherits System.Web.UI.UserControl
    Implements ICustomParams
 
    Private m_storeid As String
    Private m_CustomerID As String
    Public Property iStoreID() As String Implements ICustomParams.StoreID
        Get
            Return m_storeid
        End Get
        Set(value As String)
            m_storeid = value
        End Set
    End Property
    Public Property iCustomerID() As String Implements ICustomParams.CustomerID
        Get
            Return m_CustomerID
        End Get
        Set(value As String)
            m_CustomerID = value
        End Set
    End Property

Back in the aspx that loads the user control, add the instantiation of the interface and set the properties, like this.

Dim userControlName As String = "AppointmentDisplay.ascx"
 
Dim userControl As Control = Page.LoadControl(userControlName)
 
 
Dim ucontrol As ICustomParams = TryCast(userControl, ICustomParams)
If ucontrol IsNot Nothing Then
    ucontrol.StoreID = passedStoreID
    ucontrol.CustomerID = passedCustomerID
End If
 
userControl.ID = e.PageView.ID & "_userControl"
e.PageView.Controls.Add(userControl)

In the user control, you can reference the properties and do as needed.

Hope this helps others!

Tags
TabStrip
Asked by
Steve
Top achievements
Rank 1
Answers by
Steve
Top achievements
Rank 1
Share this question
or