updatepanel用法之triggers(局部刷新,全部刷新)使用示例

时间:2021-12-25 19:40:14

asyncpostbacktrigger(异步回调触发器):局部刷新,只刷新updatepanel内部的内容
postbacktrigger(普通回调触发器):全部刷新

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager> //必须有且一定在updatepanel前面
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
  <% =DateTime.Now.ToString()%>
</ContentTemplate>
<Triggers>
  <asp:PostBackTrigger ControlID="btn" />
  <asp:AsyncPostBackTrigger ControlID="btn2" EventName="click" />
</Triggers>
</asp:UpdatePanel>
<asp:Button runat="server" Text="刷新1" id="btn"/>
<asp:Button runat="server" Text="刷新2" id="btn2" />
<% =DateTime.Now.ToString()%>