473,503 Members | 1,677 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Server.Transfer difficulties

I've been working on some code which will hopefully allow me to transfer the
contents of an arraylist on one page over to another page. The Arraylist is
held in the viewstate object as it is populated on the on-click event of a
button. Im trying to move to another page and carry over the items in my
arraylist and write them to the page. The code ive been trying to work with
to achieve is detailed below. I am getting an error and im not sure exactly
why or what im doing wrong and was wondering if someone could have a look and
help me with this. To see exactly how my Arraylist is populated please see
my recent post. I've been advised to use the Server.Transfer to access the
arraylist on a seperate page, however as outlined below i've having some
difficulty achieveing this. Could someone please help me. Thanks

Im getting an error: -
Object reference not set to an instance of an object.
For the line
foreach (object o in debtor_enquiry.addresses)
in the page load event below.

Contained within the page where the ArrayList has been created. addresses is
the name of my arraylist.
private ArrayList Addresses1;
public ArrayList addresses
{
get
{
return Addresses1;
}
}

private void ArrayList_Click(object sender, System.EventArgs e)
{
Server.Transfer("ArrayListItemsDisplayed.aspx");
}

private void Page_Load(object sender, System.EventArgs e)
{
WebForm1 debtor_enquiry = base.Context.Handler as WebForm1;
if (null != debtor_enquiry)
{
// Add the logic here
foreach (object o in debtor_enquiry.addresses)
{
Response.Write(o.ToString());
}
}
}
Thanks again for any help anyone can give me.
Nov 16 '05 #1
1 1418
Hi Stephen:

One easay way to do this is to use the Items collection of the
HttpContext. The HttpContext collection is around for the duration of
the request, so you can shove stuff in and pull it out during a single
request, but it will be gone once the request finishes.

In the first page:

Context.Items["addresses"] = addresses;
Server.Transfer("ArrayListItemsDisplayed.aspx");

In ArrayListItemsDisplayed.aspx:

ArrayList addreses = (ArrayList)Context.Items["addresses"];
// party on the list

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 29 Oct 2004 04:52:01 -0700, "Stephen"
<St*****@discussions.microsoft.com> wrote:
I've been working on some code which will hopefully allow me to transfer the
contents of an arraylist on one page over to another page. The Arraylist is
held in the viewstate object as it is populated on the on-click event of a
button. Im trying to move to another page and carry over the items in my
arraylist and write them to the page. The code ive been trying to work with
to achieve is detailed below. I am getting an error and im not sure exactly
why or what im doing wrong and was wondering if someone could have a look and
help me with this. To see exactly how my Arraylist is populated please see
my recent post. I've been advised to use the Server.Transfer to access the
arraylist on a seperate page, however as outlined below i've having some
difficulty achieveing this. Could someone please help me. Thanks

Im getting an error: -
Object reference not set to an instance of an object.
For the line
foreach (object o in debtor_enquiry.addresses)
in the page load event below.

Contained within the page where the ArrayList has been created. addresses is
the name of my arraylist.
private ArrayList Addresses1;
public ArrayList addresses
{
get
{
return Addresses1;
}
}

private void ArrayList_Click(object sender, System.EventArgs e)
{
Server.Transfer("ArrayListItemsDisplayed.aspx");
}

private void Page_Load(object sender, System.EventArgs e)
{
WebForm1 debtor_enquiry = base.Context.Handler as WebForm1;
if (null != debtor_enquiry)
{
// Add the logic here
foreach (object o in debtor_enquiry.addresses)
{
Response.Write(o.ToString());
}
}
}
Thanks again for any help anyone can give me.


Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2086
by: Harsh Thakur | last post by:
Hi, I'd like to know the performance related differences between Response.Redirect and Server.Transfer. I'd like to redirect the user to a different page. I can either do a...
5
7802
by: Julien C. | last post by:
Hi all, I have an "EditeItem.aspx" page which lets me edit properties of an "Item". In the OnClick() event of my Save button, I do save Item changes to the database and then I redirect the user...
9
4589
by: Mark | last post by:
Hello I'm trying to use a Server.Transfer in a try-catch (I cannot put it outside the Try-Catch as it is nested deep within a component that is called in a try-catch loop) The problem is that the...
5
2555
by: Guadala Harry | last post by:
I've been reading up on Server.Transfer as well as doing some testing, and it appears to always raise the ThreadAbortException error. On one hand I've read a bunch of promotional-type material...
11
5993
by: Alexander Bosch | last post by:
Hi, I'm having a problem similar to the one that's stated in this KB http://support.microsoft.com/default.aspx?scid=kb;en-us;839521 When I'm posting a page to itself with the bool value as true it...
8
3870
by: bryan | last post by:
I've got a custom HttpHandler to process all requests for a given extension. It gets invoked OK, but if I try to do a Server.Transfer I get an HttpException. A Response.Redirect works, but I really...
6
2166
by: n# | last post by:
A Basic Question in ASP.NEt 1.1 In Page_Load Event I am doing a Server.Transfer. But it throws an error on the browser windows showing "Server Application Not Found" Pls help me
4
3986
by: evantay | last post by:
I'm using ASP.NET 2.0 with VS.NET 2005. I'm trying to access properties from my master pages within a page that inherits from that master page (a child page). However the values are always null....
2
3087
by: =?Utf-8?B?YWxiZXJ0b3Nvcmlh?= | last post by:
Hi, I'm using Threads, and when I try to do Server.Transfer, I recieved an error. (child object does not exist...) My Code: Dim t As New Thread(AddressOf Hilo) Private Sub Hilo()...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7084
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7278
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.