473,320 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

ASP.net loading page

What i'm trying to do is create a page with a loading image on it, Then
I'll start a method in a new thread that does all the work and then
fires an event which will redirect the page. Heres my code:

public partial class quote_Loading : System.Web.UI.Page
{
private delegate void LoadCompleteHandler();
private event LoadCompleteHandler LoadComplete;

protected void Page_Load(object sender, EventArgs e)
{
this.LoadComplete += new
LoadCompleteHandler(quote_Loading_LoadComplete);
}

void quote_Loading_LoadComplete()
{
Response.Redirect("loaded.aspx");
}
protected override void OnLoadComplete(EventArgs e)
{
base.OnLoadComplete(e);
System.Threading.Thread thread = new
System.Threading.Thread(new System.Threading.ThreadStart(Threads));
thread.Start();
}
public void Threads()
{
System.Threading.Thread.Sleep(1000);
this.LoadComplete();
}
}

With that code I get:
Response is not available in this context.
So then I try it with Context.Response.Redirect and I get:
Cannot redirect after HTTP headers have been sent.

I've tried clearing out the heads and everything but I have no other
idea how to get it to work :P

Feb 12 '06 #1
1 8102
Sontek,
Without going into the details of why this will not work other than the
comment that the code for an ASP.NET page is compiled, not interpreted, here
is an article that details one of a number of ways that this can be
accomplished:

http://www.eggheadcafe.com/articles/20050108.asp

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Sontek" wrote:
What i'm trying to do is create a page with a loading image on it, Then
I'll start a method in a new thread that does all the work and then
fires an event which will redirect the page. Heres my code:

public partial class quote_Loading : System.Web.UI.Page
{
private delegate void LoadCompleteHandler();
private event LoadCompleteHandler LoadComplete;

protected void Page_Load(object sender, EventArgs e)
{
this.LoadComplete += new
LoadCompleteHandler(quote_Loading_LoadComplete);
}

void quote_Loading_LoadComplete()
{
Response.Redirect("loaded.aspx");
}
protected override void OnLoadComplete(EventArgs e)
{
base.OnLoadComplete(e);
System.Threading.Thread thread = new
System.Threading.Thread(new System.Threading.ThreadStart(Threads));
thread.Start();
}
public void Threads()
{
System.Threading.Thread.Sleep(1000);
this.LoadComplete();
}
}

With that code I get:
Response is not available in this context.
So then I try it with Context.Response.Redirect and I get:
Cannot redirect after HTTP headers have been sent.

I've tried clearing out the heads and everything but I have no other
idea how to get it to work :P

Feb 13 '06 #2

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

Similar topics

2
by: Rob Tweed | last post by:
I have a customer who is having problems when their Windows 2000/IIS/PHP-based system begins to experience a level of loading that isn't, in my view, unreasonably high. I'm wondering what others...
1
by: BKM | last post by:
I've been using the following 2 ways to make sure my WebBrowser is finished loading a page before continuing with the next code. do:doevents:loop while WebBrowser.Busy do:doevents:loop until...
4
by: Adrian MacNair | last post by:
Hi, I created an image gallery which displays 63 images in a slideshow. The problem is that the show was slow because each image loaded one at a time during the show. No problem right? I just...
6
by: Curious George | last post by:
I have a page that takes about 10 seconds to load the first time it is run. I would like to first display a little animated gif telling the user that the page is loading. How do I do this with...
1
by: Angel | last post by:
Is there a way to display a message using an aspx page with controls on it that the data is loading for the page without having to display one html page then reloading the aspx page. in other words...
4
by: blackhawk | last post by:
I need to build a web page that has to potentially display a large amount of data in two grids on the same page. The HTML file with all of the formatting is about 7MB in size. This is too large...
2
by: Patrick Olurotimi Ige | last post by:
Is it possible to execute a query or do some validation before loading a page.. I have a survey page and i want to validate users before loading the page. I have done it in the page_load. But...
1
by: John Smith | last post by:
Hey folks, Got a weird one for you that I think may just be a bug with Internet Explorer. I have a page that hosts an IFrame. When I call Javascript in my page to change the source of the...
2
by: Jean Pierre Daviau | last post by:
When I have something like this in a js file. listeImg = new Array(); listeImg = new Image(w,h); listeImg.src = "centre1.jpg"; etc Are the images loaded after the page is loaded? In the same...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.