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.

 

  Modified On Nov-30-2017 12:09:21 AM

Leave Comment