使用 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
Progress bar in web application using C# and asp.net
提问by stack_pointer is EXTINCT
I need to have 2 progress bars in my application:
我的应用程序中需要有 2 个进度条:
- Circular graphical progress bar(busy indicator)
- as shown in the link [15.1.3]when the page does a postback and
- 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.
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.
但是进度条需要做更多的工作。您需要运行一个后台线程来完成这项工作,然后您需要定期回发以检查会话变量的值以获取当前进度。