SiteMap  | About    

ASP.NET Ajax Timer

The Timer control can work as a trigger to an area of the page that is wrapped with an UpdatePanel Control. It performs postbacks at defined intervals. The Interval property is defined in milliseconds, so that setting the Interval property to 5000 milliseconds will refresh the UpdatePanel control every 5 seconds.

The following program placed a Timer and label controls inside the UpdatePanel control area and one label control outside the UpdatePanel control area. When you run this program first label shows the current server time as page loaded time. After five seconds the second Label inside the UpdatePanel control shows the current server time. After that each five seconds you can see the second label only updating the current server time , because partal page updating is happening at defined intervals.



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
	<title>Untitled Page</title>
	<form id="form1" runat="server">
		<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
		<br /><br />
		<asp:ScriptManager ID="ScriptManager1" runat="server"/>
		<asp:Timer ID="Timer1" runat="server" interval="5000" ontick="Timer1_Tick" />
		<asp:UpdatePanel ID="UpdatePanel1" runat="server">
				<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
				<asp:AsyncPostBackTrigger controlid="Timer1" eventname="Tick" />

Click the following links to see full source code

C# Source Code
VB.NET Source Code
Default.aspx.vb (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.