473,729 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.P age
{
private delegate void LoadCompleteHan dler();
private event LoadCompleteHan dler LoadComplete;

protected void Page_Load(objec t sender, EventArgs e)
{
this.LoadComple te += new
LoadCompleteHan dler(quote_Load ing_LoadComplet e);
}

void quote_Loading_L oadComplete()
{
Response.Redire ct("loaded.aspx ");
}
protected override void OnLoadComplete( EventArgs e)
{
base.OnLoadComp lete(e);
System.Threadin g.Thread thread = new
System.Threadin g.Thread(new System.Threadin g.ThreadStart(T hreads));
thread.Start();
}
public void Threads()
{
System.Threadin g.Thread.Sleep( 1000);
this.LoadComple te();
}
}

With that code I get:
Response is not available in this context.
So then I try it with Context.Respons e.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 8129
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.P age
{
private delegate void LoadCompleteHan dler();
private event LoadCompleteHan dler LoadComplete;

protected void Page_Load(objec t sender, EventArgs e)
{
this.LoadComple te += new
LoadCompleteHan dler(quote_Load ing_LoadComplet e);
}

void quote_Loading_L oadComplete()
{
Response.Redire ct("loaded.aspx ");
}
protected override void OnLoadComplete( EventArgs e)
{
base.OnLoadComp lete(e);
System.Threadin g.Thread thread = new
System.Threadin g.Thread(new System.Threadin g.ThreadStart(T hreads));
thread.Start();
}
public void Threads()
{
System.Threadin g.Thread.Sleep( 1000);
this.LoadComple te();
}
}

With that code I get:
Response is not available in this context.
So then I try it with Context.Respons e.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
2055
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 think, specifically: - are these volumes, for this kind of configuration, at or beyond the levels at which PHP should be able to cope? I hope not ! - what might be done to alleviate these problems? One of our suspicions is that Windows...
1
21307
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 WebBrowser.ReadyState = STATE_COMPLETE (or something like that. I don't have the code in front of me) But, for some reason, occasionally the code continues past the loops even
4
3745
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 did a preload script. But then the user has to sit for 5 minutes waiting for 63 images to download! My images are about 640x480 and average 100kb. Is this too much for one page to load? Should I load my slideshow into differerent windows? If so,...
6
3123
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 .NET? I used to create a loading layer at the top of the page. Flush the layer to the buffer.
1
1554
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 display a message on the aspx page before all the controls are loaded and the data, then display the controls with the data all in one aspx page? or if there is another way to do this, please how... thanks
4
3285
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 and I need to implement some kind of "client side" lazy loading. What I mean is this: I want to display a grid that only shows, say, 20 records. I need an external scrollbar control that I can then show on the screen next to the grid. When...
2
1279
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 the problem i have is that if the user gets the URL and directly paste it to the browser the USER still sees the page. Is there a way how to check the user in the DB before loading the page (I mean just by pasting the URL to the browser or just by...
1
2148
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 IFrame, the blue bar in Internet Explorer starts moving as if it's loading. The problem is, the blue bar never finishes even after the page has completed loading. And yes, I am 110% certain the page has completed loading (including all js stuff). ...
2
2993
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 time? Before the page is loaded? The browser decision? If the visitors goes, before the procedure is over, to another page having a link to the same js file, will the other page allows for the rest of the
0
8770
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9299
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9227
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6029
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4541
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4800
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3251
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 we have to send another system
3
2174
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.