阅读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方法