articles

Home / DeveloperSection / Articles / Ajax Toolkit Timer Control in ASP.Net

Ajax Toolkit Timer Control in ASP.Net

John Smith14323 04-Dec-2010

Timer controls allow you to do postbacks at certain intervals. The main properties of timer control is Interval and default event of timer is Tick ()

Syntax:


<asp:Timer ID="Timer1" runat="server">
</asp:Timer>

Code:

Write these codes on aspx page

 <%-- ScriptManager control manages client script for AJAX enabled ASP.NET pages--%>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:Timer ID="UpdateTimer" runat="server" Interval="3000" OnTick="UpdateTimer_Tick" />
<%--OnTick Method Raises the Tick event.--%>
<asp:Label ID="Label1" runat="server" />

Write these code on timer event

protected void UpdateTimer_Tick(object sender, EventArgs e)
{
  Label1.Text = DateTime.Now.ToString();
}

Interval property is set in milisecond.

Run the Project

Ajax Toolkit Timer Control in ASP.Net

Page will automatically refresh after 3 second. We can change refresh time using timer control property Interval.

 


Updated 04-Mar-2020
I am best.

Leave Comment

Comments

Liked By