卡在回发中

I have created a site which runs numerous checks. These checks are started via a button and take a few minutes to complete (basically goes off runs some data checks, writes to mysql database). I then have gridview controls bound to the mysql db and when the check is complete, page refreshes and gridviews are updated.. perfect!

This is all good except the fact I can't tell the user that something is happening...

As soon as the button is checked, the site enters a long refresh status. I cant update any labels on the page to say that it's running, etc. All labels update once the c# code has completed.

I have tried a c# background worker on server to handle the long running task in the hope that the page would return and labels would update (then bind the datagrids in the background worker completes event) but no joy.. Page just waits for the background worker to complete!

I have also tried just adding an update panel, adding a label inside the panel then calling the panel.update() but again - this doesn't actually update until all code has exited.

Any non-technical ideas? All code added, much appreciated.

I think the easiest way to do this is to use the pre-made "UpdateProgress" control.

Make a new page and fire off this example that i just made to demonstrate the idea. The page has load text for when the button is clicked and after five seconds the page content changes and the load message is gone:

ASP content:

    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>

    <asp:UpdateProgress AssociatedUpdatePanelID="UpdatePanel1" runat="server">
        <ProgressTemplate>
            <p>text that indicates stuff is happening in the background (example: loading please wait)</p>         
        </ProgressTemplate>
    </asp:UpdateProgress>


    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>

            <asp:Button ID="Button1" runat="server" Text="Click me!" 
                onclick="Button1_Click" />
            <br />
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>        

        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>

CS content:

    protected void Button1_Click(object sender, EventArgs e)
    {
        //wait five seconds to demonstrate the idea
        System.Threading.Thread.Sleep(5000);

        //update page content
        Label1.Text = "Stuff in the background has finished executing and the page has been loaded with the new content.";
    }

If you have any questions lemme know but this should be fairly self explanatory to implement in whatever code you have just add the ScriptManager, the UpdateProgress control with your own load text, and put your code in the button click code behind.