Home > DeveloperSection > Beginner > Ajax Toolkit Timer Control in ASP.Net

Ajax Toolkit Timer Control in ASP.Net


AJAX AJAX 
Ratings:
0 Comment(s)
 8913  View(s)
Rate this:

Ajax Toolkit Timer Control in ASP.Net

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

AjaxControl Toolkit Timer Control in ASP.Net

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

 


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

Follow MindStick