471,330 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 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 7988
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Rob Tweed | last post: by
4 posts views Thread by Adrian MacNair | last post: by
6 posts views Thread by Curious George | last post: by
1 post views Thread by Angel | last post: by
4 posts views Thread by blackhawk | last post: by
2 posts views Thread by Patrick Olurotimi Ige | last post: by
1 post views Thread by John Smith | last post: by
2 posts views Thread by Jean Pierre Daviau | last post: by

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.