前台:
后台:
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnableScriptLocalization="true" EnablePageMethods="true">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
<asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Tick"></asp:Timer>
</div>
后台:
protected void Tick(object sender, EventArgs e)
{
this.Label1.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}