关于UpdatePanel


试了几个UpdatePanel的刷新方法,大致记录如下.

Button在UpdatePanel里面,将UpatePanel的UpdateMode设置为Always,此时ChildrenAsTriggers设置为True(设置为False将会无法编译).点击这个Button将会引起UpdatePanel的局部刷新.

若UpdateMode设置为Conditional,并添加UpdatePanel的<Triggers>属性,则引起UpatePanel刷新的Button可以不在其内部,该Button被UpdatePanel独占不能在引起全局的刷新.此时,不需要在外部使用UpdatePanel.Update()的方法.

        <triggers>
<asp:AsyncPostBackTrigger ControlID="ButtonLeaveMessage" EventName="Click" />
</triggers>

另外,值得注意的是,如果想刷新控件,必须先对控件进行重新数据绑定,比如说如果是对ViewList进行局部刷新,侧要在Button的事件中调用DataBind()方法.

我吧明白的是,什么时候要使用UpdatePanel.Update()方法,是不指定<Triggers>的时候么?我试了下,貌似不行,不知道是什么原因.

原文地址:https://www.cnblogs.com/bluecoffee/p/1339729.html