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();


Posted in Ajax. 2 Comments »

2 Responses to “How to use Ajax Timer control in”

  1. Ankit Singh Says:

    This is best one article so far I have read online. I would like to appreciate you for making it very simple and easy. I have found another nice post related to this post over the internet which also explained very well. For more details you may check it by visiting this url……..


    • Chandra Dev Says:

      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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: