惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Proofpoint News Feed
S
SegmentFault 最新的问题
The Last Watchdog
The Last Watchdog
人人都是产品经理
人人都是产品经理
C
Check Point Blog
O
OpenAI News
V
Visual Studio Blog
S
Security @ Cisco Blogs
I
InfoQ
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Troy Hunt's Blog
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
Attack and Defense Labs
Attack and Defense Labs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
SecWiki News
SecWiki News
月光博客
月光博客
U
Unit 42
博客园 - Franky
V2EX - 技术
V2EX - 技术
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
腾讯CDC
量子位
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
N
News and Events Feed by Topic
Engineering at Meta
Engineering at Meta
PCI Perspectives
PCI Perspectives
Cisco Talos Blog
Cisco Talos Blog
Google DeepMind News
Google DeepMind News
博客园 - 司徒正美
T
Tailwind CSS Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
TaoSecurity Blog
TaoSecurity Blog
Project Zero
Project Zero
WordPress大学
WordPress大学
A
Arctic Wolf
H
Help Net Security
Blog — PlanetScale
Blog — PlanetScale
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
I
Intezer
雷峰网
雷峰网
Security Latest
Security Latest
N
News and Events Feed by Topic
AI
AI
V
Vulnerabilities – Threatpost
S
Schneier on Security
Vercel News
Vercel News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

博客园 - .............

验证码生成器 十年编程无师自通 模仿桌面外观 Web服务是否失去前进目标 “开源”SOA正在改写IT规划方程式 C#实现的18位身份证格式验证算法 - ............. - 博客园 怎样使用Junit Framework进行单元测试的编写 从一个项目谈XP在国内的应用 - ............. - 博客园 AOP是什么? 在C#中使用Conditional元数据attribute来实现Debug代码 - ............. - 博客园 IBM CRM 系统解决方案 HR软件之我见-小议目前HR供应商 Atlas学习手记(11):使用ModalPopup Extender Atlas学习手记(10):使用AlwaysVisibleControl Extender Atlas学习手记(9):异步调用Page Method Atlas学习手记(8):调用本地Web Service简单介绍 Atlas学习手记(7):使用DragOverlayExtender实现拖放功能 Atlas学习手记(5):使用服务端定时控件TimerControl Atlas学习手记(4):使用AutoComplete Extender实现自动完成功能 Atlas学习手记(3):由UpdatePanel开始
Atlas学习手记(6):使用Atlas UpdateProgress控件
............. · 2006-08-03 · via 博客园 - .............

转自 TerryLee技术空间
在页面上执行较长时间的操作时,如果能够给用户提供一个类似于浏览器状态栏那样的进度条,将会使界面用户界面更加友好。在Atlas中,为我们提供的UpdateProgress控件可以轻松的实现这些。

主要内容

1UpdateProgress控件介绍

2.完整的示例

一.UpdateProgress控件介绍

在页面上执行较长时间的操作时,如果能够给用户提供一个类似于浏览器状态栏那样的进度条,将会使界面用户界面更加友好。相信大家都见到过如下这样的界面:

Atlas中,为我们提供的UpdateProgress控件可以轻松的实现类似于这样的进度条,虽然它并不是反映真实的进度,却可以使我们用户界面更加友好。一个简单的UpdateProgress控件示例代码:

<atlas:UpdateProgress ID="uprog" runat="server">

    
<ProgressTemplate>

        
<div style="background-color: #E2F2FF; color: Black; font-size:10pt; position: absolute; left: 10px;

            top: 40px; width: 300px; height: 120px; border:solid 1px #8DD3FF"
>

            数据更新中,请稍候

            
<p></p>

           
&nbsp;&nbsp;&nbsp;&nbsp;<img src="images/loading02.gif" alt="Progress"/>

        
</div>

    
</ProgressTemplate>

</atlas:UpdateProgress>

UpdateProgress控件并没有什么属性需要去设置,我们唯一要做的就是设置ProgressTemplate,即进度条在页面上显示的样式,可以是图片,文本等,这一点类似于我们前面说过的ErrorTemplate

二.完整的示例

UpdateProgress控件的使用相当简单,下面看一个例子,在该示例中,我们在更新一段文本时执行长时间的操作。还是先添加ScriptManager控件:

<atlas:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server" />

在添加一个UpdatePanel,用来更新文本:

<atlas:UpdatePanel ID="upanel" runat="server">

    
<ContentTemplate>

        
<div style="background-color: white; position: absolute; left: 10px; top:40px;

            width: 300px; height: 150px"
>

            
<asp:Label Font-Bold="true" Font-Size="XX-Large" ID="thelabel" runat="server">I will be updated</asp:Label>

        
</div>

    
</ContentTemplate>

    
<Triggers>

        
<atlas:ControlEventTrigger ControlID="button1" EventName="Click" />

    
</Triggers>

</atlas:UpdatePanel>

现在添加UpdateProgress控件,设置ProgressTemplate<div>来实现:

<atlas:UpdateProgress ID="uprog" runat="server">

    
<ProgressTemplate>

        
<div style="background-color: #E2F2FF; color: Black; font-size:10pt; position: absolute; left: 10px;

            top: 40px; width: 300px; height: 120px; border:solid 1px #8DD3FF"
>

            数据更新中,请稍候

            
<p></p>

           
&nbsp;&nbsp;&nbsp;&nbsp;<img src="images/loading02.gif" alt="Progress"/>

        
</div>

    
</ProgressTemplate>

</atlas:UpdateProgress>

添加一个按钮,在它的事件中更新上面的文本:

protected void button1_Click(object sender, EventArgs e)

{
    
// 模拟长时间的操作

    System.Threading.Thread.Sleep(
5000);


    thelabel.Text 
= string.Format("I've been updated at {0}", DateTime.Now.ToLongTimeString());

}

至此整个示例就完成了,编译运行,看一下效果:

单击“更新”按钮

更新完成后:


UpdateProgress控件使用需要的几点:

1UpdateProgress控件并不是为某一个控件的处理而添加的,它是一个全局的控件,对整个页面都有效,所以在页面只能有一个且只能添加一个UpdateProgress控件。所有涉及到延时的操作都会由UpdateProgress控件来处理。

2UpdateProgress控件的Template中有一个IDabortButtonButton控件,我们可以提供一个服务器端ButtonLinkButton控件,并指定IDabortButton,以使用户可以取消当前的操作。示例代码如下:

<atlas:UpdateProgress ID="uprog" runat="server">

    
<ProgressTemplate>

        
<div style="background-color: #E2F2FF; color: Black; font-size:10pt; position: absolute; left: 10px;

            top: 40px; width: 300px; height: 120px; border:solid 1px #8DD3FF"
>

            数据更新中,请稍候

            
<p></p>

           
&nbsp;&nbsp;&nbsp;&nbsp;<img src="images/loading02.gif" alt="Progress"/>

            
<asp:Button ID="abortButton" runat="server"/>

        
</div>

    
</ProgressTemplate>

</atlas:UpdateProgress>


完整示例下载:https://files.cnblogs.com/Terrylee/UpdateProgressDemo.rar