简体   繁体   English

<ASP.NET>在文件创建过程中显示一个等待对话框,并在下载完成后将其隐藏

[英]<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 查看jQuery BlockUI插件

I have used the RadProgressArea control from the Telerik RadControls for ASP.NET AJAX suite to report back progress of long-running operations. 我使用了Telerik RadControls for ASP.NET AJAX套件中的RadProgressArea控件来报告长期运行的操作进度。 It works quite well for that scenario as it polls the process for status updates. 对于这种情况,它轮询状态更新的过程非常有效。

Adding to Colin's response: 加上Colin的回应:

You can find a demo of the RadProgressArea here: 您可以在此处找到RadProgressArea的演示:

http://demos.telerik.com/aspnet-ajax/upload/examples/customprogress/defaultcs.aspx 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. ProgressArea与RadProgressManager结合使用以轮询服务器进程并更新客户端UI。 There is a client-side API for the ProgressManager that allows you to start and hide the progress area via JavaScript: ProgressManager有一个客户端API,可让您通过JavaScript启动和隐藏进度区域:

http://www.telerik.com/help/aspnet-ajax/upload_clientsideradprogressmanager.html 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): 还有一个在线演示,向您展示如何将ProgressArea放置在RadWindow中(您的要求中的“对话框”):

http://www.telerik.com/support/kb/aspnet-ajax/window/using-radupload-progress-area-in-radwindow.aspx 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. ProgressManager / Area最终使用HttpHandler来促进进度更新,并且如果您在Webfarm中,该技术确实需要“粘性会话”。 Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM