示例ASPX页面代码: <% ... @ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AJAXTIMESIMPLE._Default" %> <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > < html xmlns ="http://www.w3.org/1999/xhtml" > < head runat ="server" > < title > Untitled Page </ title > </ head > < body > < form id ="form1" runat ="server" > < asp:ScriptManager ID ="ScriptManager1" runat ="server" /> < div > < asp:UpdatePanel ID ="UpdatePanel1" runat ="server" > < ContentTemplate > < asp:Timer ID ="Timer1" runat ="server" Interval ="10000" OnTick ="Timer1_Tick" > </ asp:Timer > < asp:Label ID ="lblRefresh" runat ="server" Text ="Panel not refreshed yet" Width ="174px" ></ asp:Label > </ ContentTemplate > </ asp:UpdatePanel > < asp:Label ID ="lblNoFresh" runat ="server" ></ asp:Label ></ div > </ form > </ body > </ html > 示例后台C#代码: using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; namespace AJAXTIMESIMPLE ... { public partial class _Default : System.Web.UI.Page ...{ protected void Page_Load(object sender, EventArgs e) ...{ lblNoFresh.Text = "Page created at: " + DateTime.Now.ToLongTimeString(); } protected void Timer1_Tick(object sender, EventArgs e) ...{ lblRefresh.Text = "Panel refreshed at: " + DateTime.Now.ToLongTimeString(); } }}