Hi,
this is an ideal scenario for theUpdatePanel control. The page can be refreshed at regular intervals by aTimer control. Check the following example:
<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void TheTimer_Tick(object sender, EventArgs e) { lblUpdate.Text = DateTime.Now.ToString(); }</script><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="TheScriptManager" runat="server"></asp:ScriptManager><%-- Timer --%> <asp:Timer ID="TheTimer" runat="server" Interval="2000" OnTick="TheTimer_Tick"></asp:Timer><%-- UpdatePanel --%> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <Triggers> <asp:AsyncPostBackTrigger ControlID="TheTimer" EventName="Tick" /> </Triggers> <ContentTemplate> <asp:Label ID="lblUpdate" runat="server"></asp:Label> </ContentTemplate> </asp:UpdatePanel> </form></body></html>
No comments:
Post a Comment