views:

36

answers:

1

Hi,

I have a search form on a page that posts back to itself and shows the results, all works fine. I now have a requirement to put the same search form on the site home page. This needs to post back to the search form and run the findResults code. Using the PostBackURL parameter on the home page form's submit button I can hit the search page ok. However, when using the following code in the Page_Load section of the search page I hit the problem of not being able to access data from the posting page as I get the following error message on the line starting "yearList.SelectedValue....": "'Site._default1.Protected WithEvents yearList As System.Web.UI.WebControls.DropDownList' is not accessible in this context because it is 'Protected'".

  '#################################
  '# Handle form post from Home page
  '#################################
  Dim crossPostBackPage As Site._default1
  If Not (Page.PreviousPage Is Nothing) Then

   If Not (Page.IsCrossPagePostBack) Then

    If (Page.PreviousPage.IsValid) Then
     crossPostBackPage = CType(PreviousPage, Site._default1)
     yearList.SelectedValue = crossPostBackPage.yearList.SelectedValue
     getAvailability()
    End If
   End If
  End If

As I didn't declare yearList Protected, I don't know where to change it or how to.

Any advice would be appreciated,

Craig

A: 
dim prevYearList as ListBox = CType(PreviousPage.FindControl("yearList"),ListBox)

reference: http://msdn.microsoft.com/en-us/library/ms178139.aspx

note: the vb is a quick off the top of my head translation of my tested c# code, so don't take it literally.

Sky Sanders