asp.net页面时间实时更新—UpdatePanel的应用

来源:互联网 发布:mac照片和文稿里的图片 编辑:程序博客网 时间:2024/06/08 06:39

原文地址:点击打开链接


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

0 0
原创粉丝点击