使用 C# 和 asp.net 的 Web 应用程序中的进度条

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/874976/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 05:02:45  来源:igfitidea点击:

Progress bar in web application using C# and asp.net

c#asp.net

提问by stack_pointer is EXTINCT

I need to have 2 progress bars in my application:

我的应用程序中需要有 2 个进度条:

  1. Circular graphical progress bar(busy indicator)
    • as shown in the link [15.1.3]when the page does a postback and
  2. A determinate progress bar
    • as shown in the link [15.1.1]with showing a percentage when I update or load data into the grid which I use in my application.
  1. 圆形图形进度条忙指示符)
    • 如链接[15.1.3] 中所示,当页面进行回发时
  2. 一个确定的进度栏
    • 如链接[15.1.1] 中所示,当我将数据更新或加载到我在应用程序中使用的网格中时,会显示一个百分比。

Can anyone help me with code snippets and how I can proceed with my .aspx and .aspx.cs files in order to obtain these progress bars for my application?

任何人都可以帮助我获取代码片段以及如何处理我的 .aspx 和 .aspx.cs 文件以获得我的应用程序的这些进度条?

回答by Daniel

You can use an UpdateProgress control for the busy indicator, which is very easy:

您可以对忙碌指示器使用 UpdateProgress 控件,这非常简单:

   <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1" DisplayAfter="0">
       <ProgressTemplate>
           <div>
               <img src="../Resources/Images/indicator.gif" />
               Loading...
           </div>
       </ProgressTemplate>
   </asp:UpdateProgress>

But a progress bar is going to require a bit more work. You'll need to run a background thread to do the work, and you'll then need to periodically post back to check the value of, say, session variable to get your current progress.

但是进度条需要做更多的工作。您需要运行一个后台线程来完成这项工作,然后您需要定期回发以检查会话变量的值以获取当前进度。