borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB Home | News Home | Forum Home | Downloads | Register | Search | PM | Profile

Previous Topic (VB Article - How to avoid security prompts in Visual Basic programs for Outlook)Next Topic (XML.. and MSXML4 <-- medium VB, basic XML) New Topic Post Reply
AndreaVB OnLine : Articles and tutorials : Passing Objects from page to page
Poster Resource
dcostelloe
Level: VB Guru

Registered: 11-06-2002
Posts: 74
icon Passing Objects from page to page

Hi all,
Someone in another group asked me how to pass objects from page to page using vb.net and ASP.Net.
Here is the sample:
On the page sending the data add a property:
This example uses an ArrayList but you can use whatever you want.

Page1.aspx Code
=============
Declare Section

Private arList1 as ArrayList = New ArrayList

On Page_Load
===========
Add data to ArrayList
Dim x as Int32

for x = 0 to 10
arlist1.Add( "Sample" & x)
Next x
' Add this to Page1
Public ReadOnly Property ArListData() As ArrayList
        Get
          Return arList1
        End Get
    End Property

Page2.aspx
=========
This is the receiver Page
Declare Section
Private objPage As Page1
Private arrList as arraylist = new Arraylist()

Page_Load
========
If Not IsPostBack Then
      objPage = CType(Context.Handler, Page1)
      arrList = objPage.arList1
End If

In the HTML Section of Page2 add the following:
<%@ Reference Page="Page1.aspx"%>

The final part is to load page2 from Page1
This example Uses Button Click Event on page1.

Private Sub btnClick_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClick.Click
        ' Load Page 2 Here
        Server.Transfer("Page2.aspx", False)

End Sub

You can pass pretty much anything with a reasonable impact on your system.
You can also use the session variable with a impact to your web server and application.



____________________________
Life is but a merry go round
around and around :-)

Visit us today:
http://www.welford-costelloe.com

30-07-2002 at 10:40 AM
View Profile Send Email to User Show All Posts Visit Homepage | Add Comment
johnedw
Level: Sage

Registered: 15-08-2004
Posts: 50
icon Re: Passing Objects from page to page

Thanks , this was very helpful.


____________________________
Today is a new day, in
a world OF CODE!

15-08-2004 at 10:41 PM
View Profile Send Email to User Show All Posts ICQ | Add Comment
AndreaVB OnLine : Articles and tutorials : Passing Objects from page to page
Previous Topic (VB Article - How to avoid security prompts in Visual Basic programs for Outlook)Next Topic (XML.. and MSXML4 &lt;-- medium VB, basic XML)New Topic Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder