How to use Ajax Timer control in

If our requirement to update some portion of page on basis of some time interval, then we can use “Ajax Timer” control. Here I m updating the system date on some time interval (2 sec).

We can do like this

Step1: Take ScriptManager,Timer,UpdatePanel, Label control and arrange the code like this

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TimerControl.aspx.cs" Inherits="TimerControl" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""&gt;

<html xmlns=""&gt;
<head runat="server">
<form id="form1" runat="server">

<asp:ScriptManager ID="ScriptManager1" runat="server"/>

<asp:Timer ID="Timer1" Interval="2000" runat="server" ontick="Timer1_Tick"/>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />



<p>Date will update on interval of 2 secounds</p>

<asp:Label ID="LblDate" runat="server" Font-Bold="true" ForeColor="Red" Text=""></asp:Label>



Step2:Write the code in code behind page like this

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class TimerControl : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)

protected void Timer1_Tick(object sender, EventArgs e)

LblDate.Text = System.DateTime.Now.ToString();



2 thoughts on “How to use Ajax Timer control in

    • Chandra Dev January 9, 2012 / 5:20 pm

      Thanks for sharing the URL and you are welcome.I m glad to hear nice feedback from you.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.