How can I pass querystring values to page loaded in PageView

2 posts, 0 answers
  1. Steve
    Steve avatar
    84 posts
    Member since:
    Aug 2013

    Posted 17 Nov 2013 Link to this post

    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?
  2. Steve
    Steve avatar
    84 posts
    Member since:
    Aug 2013

    Posted 17 Nov 2013 Link to this post

    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!

  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top