2011-10-24 51 views
1

我想要傳遞一些值到另一個頁面,我有列表(字符串)中的值。但是,我在設計時出現錯誤(,在IDE中),他說:System.Web.UI.Page沒有成員「X」。我可以通過智能感知獲得該物業。所以我不確定爲什麼我會得到這個錯誤。如何通過PreviousPage屬性傳遞列表?

下面的代碼:

'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 

回答

1

的Server.Transfer不會做回發到頁面上。我相信(但是我已經使用PreviousPage已經很長時間了),它只有當你在控件上的PostBackURL屬性時才起作用。

+0

Server.Transfer似乎現在工作的方式很好。 – dotnetN00b

0

看來,即使IDE將其標記爲錯誤,代碼編譯並運行良好。我不確定我是否幸運,IDE是越野車,或者是某種未定義的行爲。