转 http://read.newbooks.com.cn/info/178383.htmlhttp://read.newbooks.com.cn/info/178383.html
在使用的时候 有个是否占位的属性不要设置为true,延迟时间也需要设置大点,当你的业务计算时间比较大的时候.
下边是网上找的文章,挺有用的
在updatePanel里面放了一个Button和Label,然后点击Button给Label赋值。这个是个很简单的过程了。
代码我就补贴了。
然后我再加了一个UpdateProgress控件,把它的AssociatedUpdatePanelID指向刚加的UpdatePanel,其代码如下:
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
Button事件:
protected void Button1_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
Label1.Text = DateTime.Now.ToString();
}
然后我把updateProgress拿到updatePanel控件外面来,运行,正常。
然后我再把button控件拿到updatePannel控件外面来,然后又在updatepanel里面加上triggers,代码如下:
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
难道使用triggers的调用外部控件来进行异步传输,不会引发UpdateProgress?
后来在网上找到了解决方法:
在代码里面加入如下js:
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711118.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711686.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711207.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711686.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711962.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711686.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711686.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711686.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711207.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711686.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711686.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711686.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711962.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711433.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711118.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711686.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711207.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711686.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711962.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711686.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711433.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
然后运行正常,从上面的js可以看出,如果是triggers触发的button事件,那么progress控件的style.display始终都是none,在button_click事件触发时,并没有使progress的 style.display变成block。所以里面的"更新中..."显示不出来。
再如:
<div id="divUpdateProgress" style="position: absolute; right: 466px; top: 48px; height: 20px;">
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<div style="font-size: 12px; color: Blue; background-color: #FFFFD6; border: solid 1px blue;">
<img src="../Image/ajaxloader.gif" />
数据加载中,请稍候
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</div>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<div style="font-size: 12px; color: Blue; background-color: #FFFFD6; border: solid 1px blue;">
<img src="../Image/ajaxloader.gif" />
数据加载中,请稍候
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</div>
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711118.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711686.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711207.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711686.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711962.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711686.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711686.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711686.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711686.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711207.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711686.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711962.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711433.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711118.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711686.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711207.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711686.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711962.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711686.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711433.gif)
![](http://www.newbooks.com.cn/infos/pic/200801/178383/20080105010711582.gif)