Home > DeveloperSection > Articles > ASP.Net AJAX Server Control: Timer

ASP.Net AJAX Server Control: Timer

1 Comment(s)
 5990  View(s)
Rate this:

ASP.Net AJAX Server Control: Timer

Timer: The timer control will execute client side event s at specific interval and allows specific part so your page to update or refresh at these moments.

How we implement the Timer server control


Step1: we use the following control on aspx page




  <form id="form1" runat="server">


    <%--Using ScriptManger Control--%>

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


    <%--Using UpdatePanel Control--%>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">


    <%-- Using Label And Timer Control inside UpdatePanel--%>

    <asp:Label ID="lblDateTime" runat="server" Text=""> </asp:Label>

    <asp:Timer ID="Timer1"runat="server"Interval="9000"OnTick= "Timer1_Tick">








Step2: We write the following code on Timer1_Tick event.



protected void Page_Load(object sender, EventArgs e)


if (!Page.IsPostBack)


lblDateTime.Text ="Start DateTime: "+ DateTime.Now.ToString();



protected void Timer1_Tick(object sender, EventArgs e)


lblDateTime.Text ="By Timer: "+ DateTime.Now.ToString();



Step3: Run the project



After Sometimes, the output is:


 This is the simple example of Timer and UpdatePanel control, how we use these control in our web based project or window based project.


By Sunil Singh on   2 months ago

This article is truly nice.

Don't want to miss updates? Please click the below button!

Follow MindStick