閱讀850 返回首頁    go 阿裏雲 go 技術社區[雲棲]


asp.net頁麵時間實時更新—UpdatePanel的應用

 

<asp:ScriptManager ID="ScriptManager1" runat="server">
 </asp:ScriptManager>

 

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">

<ContentTemplate>
   <asp:Label ID="lblTime" runat="server" Text=""></asp:Label>
</ContentTemplate>
<Triggers>
   <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>

</asp:UpdatePanel>
           

<asp:Timer ID="Timer1" runat="server" ontick="Timer1_Tick" Interval="1000">
</asp:Timer>

 

protected void Timer1_Tick(object sender, EventArgs e)

{
   this.lblTime.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
}

最後更新:2017-04-02 22:16:00

  上一篇:go Sql Server使用存儲過程
  下一篇:go FindControl——對母版頁使用FindControl方法