如何通过 PreviousPage 属性传递列表?
我正在尝试将一些值传递到另一个页面,并且列表(字符串)中有这些值。但是,我收到一条错误(在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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.
看起来,即使 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.