如何通过 PreviousPage 属性传递列表?

发布于 2024-12-11 18:33:21 字数 2063 浏览 0 评论 0原文

我正在尝试将一些值传递到另一个页面,并且列表(字符串)中有这些值。但是,我收到一条错误(在 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

I'm trying to pass some values to another page and I have the values in List (Of String). However, I'm getting an error (at design-time in the IDE) saying: There is no member "X" of System.Web.UI.Page. I was able to get the Property through Intellisense. So I'm not sure why I'm getting the error.

Here's the code:

'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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

溺ぐ爱和你が 2024-12-18 18:33:21

Server.Transfer 不会回发到页面。我相信(但是自从我使用 PreviousPage 以来已经很长时间了)它仅在您使用控件上的 PostBackURL 属性时才有效。

Server.Transfer wouldn't do a postback to the page. I believe (however it's been a long time since I have used PreviousPage) that it only works when you the the PostBackURL property on a control.

沉鱼一梦 2024-12-18 18:33:21

看起来,即使 IDE 将其标记为错误,代码也可以编译并运行良好。我不确定我是否幸运,IDE 有问题,或者是某种未定义的行为。

It seems that even though the IDE marked it as an error, the code compiled and ran fine. I'm not sure if I'm lucky, the IDE is buggy, or it's some sort of undefined behavior.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文