1. 程式人生 > >asp.net頁面時間實時更新—UpdatePanel的應用

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”);
}

轉載:https://blog.csdn.net/dqs78833488/article/details/52441475