| Author: Antony s Nasarath 11 Oct 2008 | Member Level: Silver | Rating: Points: 6 |
You can use asp.net with Ajax to do this. For this you should need visual studio 2005 or higher.
If you are using VS 2005, you should create Ajax enable web site.
1. Add script manager to web form 2.Add update panel and add the contant you want, in this case i added a lable and timer. 3.Add asynchoronus trigger to handle tick event of timer control. 4.Create timer tick event and add code to display in the lable control
Code sample <!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>Test site</title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <br /> <asp:Timer ID="Timer1" runat="server" ontick="Timer1_Tick"> </asp:Timer> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /> </Triggers> </asp:UpdatePanel> </div> </form> </body> </html>
Timer click event
protected void Timer1_Tick(object sender, EventArgs e) { this.Label1.Text = DateTime.Now.ToString(); }
In timer proper you should enable timer and set interval to trigger every minut (60000 mill sec).
In the example above, timer event update timer every minute.
Regards, Antony
|