如何通过PreviousPage属性传递List?

时间:2011-10-24 16:01:18

标签: vb.net visual-studio-2008 asp.net-3.5

我正在尝试将一些值传递给另一个页面,并且我在List(Of String)中有值。但是,我收到一个错误(在IDE的设计时 )说:System.Web.UI.Page没有成员“X”。我能够通过Intellisense获得财产。所以我不确定为什么我会收到错误。

以下是代码:

'Source Page (Default.aspx)-

Private locationDetails As List(Of String)
    Public ReadOnly Property LocationsForDetail() As List(Of String)
        Get
            Return locationDetails
        End Get
    End Property

    Private loadDetails As List(Of String)
    Public ReadOnly Property LoadsForDetail() As List(Of String)
        Get
            Return loadDetails
        End Get
    End Property

    Private optionDetails As List(Of String)
    Public ReadOnly Property OptionsForDetail() As List(Of String)
        Get
            Return optionDetails
        End Get
    End Property

    Protected Sub RadButton2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadButton2.Click

        For Each facility As ListItem In CheckBoxList1.Items
            If facility.Selected Then
                locationDetails.Add(facility.Text)
            End If
        Next

        For Each load As ListItem In CheckBoxList2.Items
            If load.Selected Then
                loadDetails.Add(load.Text)
            End If
        Next

        optionDetails.Add(DropDownList2.SelectedValue)
        optionDetails.Add(DropDownList3.SelectedValue)
        optionDetails.Add(DropDownList4.SelectedValue)
        optionDetails.Add(RadDatePicker1.SelectedDate.Value.ToShortDateString)
        optionDetails.Add(RadDatePicker2.SelectedDate.Value.ToShortDateString)

        Server.Transfer("Breakdown.aspx")
    End Sub


'Target Page (Breakdown.aspx) -

    Protected Sub populateChart()

        Dim locations As List(Of String) = PreviousPage.LocationsForDetail 'get error here
        Dim capacities As List(Of String) = PreviousPage.LoadsForDetail    'get error here
        Dim rescOptions As List(Of String) = PreviousPage.OptionsForDetail 'get error here

        bindData.populateChart(RadChart1, locations, capacities, rescOptions)
    End Sub

2 个答案:

答案 0 :(得分:1)

Server.Transfer不会对页面进行回发。我相信(但是我使用PreviousPage已经有很长一段时间了)它只适用于控件上的PostBackURL属性。

答案 1 :(得分:0)

似乎即使IDE将其标记为错误,代码也已编译并运行良好。我不确定我是否幸运,IDE是有缺陷的,或者它是某种未定义的行为。