List Info

Thread: ASP.net loading page




ASP.net loading page
user name
2006-02-12 11:13:20
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

ASP.net loading page
user name
2006-02-14 16:31:22
Hello Sontek,
it won't be possible to do what you are trying in such a
manner. In the
very least you need a combination of .net and client
javascript and it
is way to convoluted to just write out at your present
state.
I would suggest going back to something a little bit less
fancy until
you understand the basics better. I would read some info in
requests
and responses as it relates to http if I were you.

Marty

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )