updatepanel的用法之triggers

时间:2022-06-03 23:27:28

triggers有的两种触发器asyncpostbacktrigger和postbacktrigger。
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()%>