<ASP.NET> Show a wait dialog during file creation and hide it when download is ready
I have a Page that automatically generates a file and sends it to the Response. I need a Dialog to be shown during the file creation and hidden after 开发者_运维问答the browser download dialog appears. Any suggestion?
Thanks! :)
You can show a nice overlay busy message.
The Mark-up part:
$(function() { // when document has loaded
($.unblockUI); //unlock UI
//Show busy message on click event and disable UI
$('#btnHelloWorld').click(function() {
$.blockUI({ message: '<h4><img src="busy.gif" />Please wait...</h4>' });
});
});
<asp:Button ID="btnHelloWorld" runat="server" Text="Hello World" /><br/>
The Code behind:
Protected Sub btnHelloWorld_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnHelloWorld.Click
Label1.Text = "Hello World"
Threading.Thread.Sleep(5000)
End Sub
Check out jQuery BlockUI Plugin
I have used the RadProgressArea control from the Telerik RadControls for ASP.NET AJAX suite to report back progress of long-running operations. It works quite well for that scenario as it polls the process for status updates.
Adding to Colin's response:
You can find a demo of the RadProgressArea here:
http://demos.telerik.com/aspnet-ajax/upload/examples/customprogress/defaultcs.aspx
The ProgressArea works in conjunction with the RadProgressManager to poll the server process and update the client UI. There is a client-side API for the ProgressManager that allows you to start and hide the progress area via JavaScript:
http://www.telerik.com/help/aspnet-ajax/upload_clientsideradprogressmanager.html
There is also an online demo showing you how to place ProgressArea in a RadWindow (the "dialog" in your requirements):
http://www.telerik.com/support/kb/aspnet-ajax/window/using-radupload-progress-area-in-radwindow.aspx
The ProgressManager/Area ultimately use a HttpHandler to facilitate the progress updates, and the technique does require "sticky session" if you're in a webfarm. Hope that helps.
精彩评论