当前位置: 移动技术网 > IT编程>开发语言>.net > asp.net UpdaeProgress的简单用法

asp.net UpdaeProgress的简单用法

2018年04月20日  | 移动技术网IT编程  | 我要评论

oqueenz,装修保修卡,榕叶满庭莺乱啼

updateprogress 应该就是“更新进度” 的意思吧。
使用方法:
1.添加一个scriptmanager控件
2.添加一个updatepanel控件
3.添加一个updateprogress控件
设置updateprogress控件的associatedupdatepanelid为第2步 updatepanel的id(如果页面中有多个updatepanel则,只有相应updatepanel关联的updateprogress显示)
测试例子代码: 
复制代码 代码如下:

<%@ page language="c#" autoeventwireup="true" codefile="default.aspx.cs" inherits="_default" %>
<%@ register assembly="ajaxcontroltoolkit" namespace="ajaxcontroltoolkit" tagprefix="cc1" %>
<!doctype html public "-//w3c//dtd xhtml 1.1//en" "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="head1" runat="server">
<title>untitled page</title>
<style type="text/css">
#updatepanel1, #updatepanel2, #updateprogress1 {
border-right: gray 1px solid; border-top: gray 1px solid;
border-left: gray 1px solid; border-bottom: gray 1px solid;
}
#updatepanel1, #updatepanel2 {
width:200px; height:200px; position: relative;
float: left; margin-left: 10px; margin-top: 10px;
}
#updateprogress3 {
width: 200px; background-color: #ffc080;
bottom: 0%; left: 0px; position: absolute;
}
#updateprogress2 {
width: 200px; background-color: #ffc080;
bottom: 0%; left: 0px; position: absolute;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:scriptmanager id="scriptmanager1" runat="server" />
<asp:updatepanel id="updatepanel1" runat="server">
<contenttemplate>
<asp:button id="button1" runat="server" onclick="button1_click1" text="button" />
<asp:label id="label1" runat="server" text="显示数据"></asp:label>
<asp:updateprogress id="updateprogress1" runat="server" associatedupdatepanelid="updatepanel1">
<progresstemplate>
<div id="progress"><img src="img/1.gif" />
等待中...
</div>
</progresstemplate>
</asp:updateprogress>
</contenttemplate>
</asp:updatepanel>
<asp:updatepanel id="updatepanel2" runat="server">
<contenttemplate>
<asp:button id="button2" runat="server" onclick="button2_click1" text="button" /><br />
<br />
<asp:label id="label2" runat="server" text="显示数据"></asp:label>
<asp:updateprogress id="updateprogress2" runat="server" associatedupdatepanelid="updatepanel2">
<progresstemplate>
更新数据中....
</progresstemplate>
</asp:updateprogress>
</contenttemplate>
</asp:updatepanel>
</form>
</body>
</html>

c#代码:
复制代码 代码如下:

using system;
using system.data;
using system.configuration;
using system.web;
using system.web.security;
using system.web.ui;
using system.web.ui.webcontrols;
using system.web.ui.webcontrols.webparts;
using system.web.ui.htmlcontrols;
using system.threading;
public partial class _default : system.web.ui.page
{
protected void page_load(object sender, eventargs e)
{
}
protected void button1_click1(object sender, eventargs e)
{
system.threading.thread.sleep(3000);
label1.text = "刷新时间:" + datetime.now.tostring();
}
protected void button2_click1(object sender, eventargs e)
{
system.threading.thread.sleep(3000);
label2.text = "刷新时间:" + datetime.now.tostring();
}
}

其中,页面代码中的css是msdn上的例子。updatepanel1中的updateprogress1显示一张动态gif图片
还往大哥大姐们多多指教。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网