retrieving data from the last pageS

G

Giggi

Hi!
I have a little problem... I have 3 pages:
users should go from page1 to page2 and then to page3
In page1 there is an arraylist, and I can access it from page2 using
the PreviousPageType directive and a public property in page1.

My problem is: how can I access the arraylist in page1 from page3?
I tried to define a public property in page2 that returns
"previouspage.arraylist" but it doesn't work.
Any idea?

Thank you in advance!!

Giggi
 
E

Eliyahu Goldin

Giggi,

Page 1 is available only to Page 2. Page 2 will need to save the info in one
of its properties to make it available to Page 3. It could be easier just to
use session variables that are available to all pages in the application.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 
L

Laurent Bugnion [MVP]

Hi,
Hi!
I have a little problem... I have 3 pages:
users should go from page1 to page2 and then to page3
In page1 there is an arraylist, and I can access it from page2 using
the PreviousPageType directive and a public property in page1.

My problem is: how can I access the arraylist in page1 from page3?
I tried to define a public property in page2 that returns
"previouspage.arraylist" but it doesn't work.
Any idea?

Thank you in advance!!

Giggi

Note that the pages are only instantiated when the request is active,
and they are recycled after the response is sent. If your arraylist must
be accessible from other objects, you should define it static (but then
be careful for possible memory leaks).

Once the static arraylist exists, you can access it with

Page1.MyStaticArrayList

If you cannot define it static, then you must create a instance of Page1
before using the property, but I would try to avoid this. If this must
really be an instance property, I would rather export the ArrayList to
an external object used by Page1 and Page3.

HTH,
Laurent
 
A

Aidy

I wouldn't rcommend using static variables as the data is probably session
specific. I'd also store the info in the Session.

Laurent Bugnion said:
Hi,
Hi!
I have a little problem... I have 3 pages:
users should go from page1 to page2 and then to page3
In page1 there is an arraylist, and I can access it from page2 using
the PreviousPageType directive and a public property in page1.

My problem is: how can I access the arraylist in page1 from page3?
I tried to define a public property in page2 that returns
"previouspage.arraylist" but it doesn't work.
Any idea?

Thank you in advance!!

Giggi

Note that the pages are only instantiated when the request is active, and
they are recycled after the response is sent. If your arraylist must be
accessible from other objects, you should define it static (but then be
careful for possible memory leaks).

Once the static arraylist exists, you can access it with

Page1.MyStaticArrayList

If you cannot define it static, then you must create a instance of Page1
before using the property, but I would try to avoid this. If this must
really be an instance property, I would rather export the ArrayList to an
external object used by Page1 and Page3.

HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
 
G

Giggi

Eliyahu said:
Giggi,

Page 1 is available only to Page 2. Page 2 will need to save the info in one
of its properties to make it available to Page 3.

Hi!

Thank you everybody!!
That would be perfect, could you please give a few lines of example?
That's what I have:

----Page1.aspx----
<script runat="server">
Public ReadOnly Property dest() As ArrayList
Get
Dim dest_list As New ArrayList
...'takes data from some checkboxes selected on the page
Return dest_list
End Get
End Property
</script>

----Page2.aspx----
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
'gets array from previous page
Dim dest_list As ArrayList = PreviousPage.dest() '<-- doesn't
work when called by Page3!!!
End Sub

Public ReadOnly Property get_dest() As ArrayList
'returns array to the next page
Get
Return dest_list '<--- this is out of scope!!
End Get
End Property
</script>

----Page3.aspx----
....
Dim destinatari As ArrayList = PreviousPage.get_dest()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top