This documentation is archived and is not being maintained.

Timer.Interval Property

Gets or sets the number of milliseconds to wait before initiating a postback.

Namespace:  System.Web.UI
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)

public int Interval { get; set; }
<asp:Timer Interval="Int32" />

Property Value

Type: System.Int32
The number of milliseconds to wait before initiating a postback. The default value is 60,000 (60 seconds).


The specified value is less than or equal to zero.

Use the Interval property to set how often the Timer control initiates a postback to the server. You can change the value of the Interval property in server code after a postback, such as in an event handler for the Tick event. The accuracy of when the Timer control posts back to the Web server depends on the accuracy of the ECMAScript (JavaScript) window.setTimeout function that runs in the browser.


Setting the Interval property to a small value can generate significant traffic to and from the Web server. Use the Timer control to refresh the content only as often as necessary.

When you change the value of the Interval property, the ECMAScript timing code running in the browser will be reset when the updates are rendered.

The following example shows an UpdatePanel control that displays a randomly generated stock price and the time that the stock price was generated. By default, the Timer control updates the content in the UpdatePanel control every 10 seconds. The user can decide to update the stock price every 10 seconds, every 60 seconds, or not at all. The Interval property is set to the user's choice.

<%@ Page Language="C#" AutoEventWireup="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">
<html xmlns="">
<head id="Head1" runat="server">
    <title>Timer Example Page</title>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
            OriginalTime.Text = DateTime.Now.ToLongTimeString();

        protected void Timer1_Tick(object sender, EventArgs e)
            StockPrice.Text = GetStockPrice();
            TimeOfPrice.Text = DateTime.Now.ToLongTimeString();

        private string GetStockPrice()
            double randomStockPrice = 50 + new Random().NextDouble();
            return randomStockPrice.ToString("C");

        protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
            Timer1.Enabled = true;
            Timer1.Interval = 10000;

        protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
            Timer1.Enabled = true;
            Timer1.Interval = 60000;

        protected void RadioButton3_CheckedChanged(object sender, EventArgs e)
            Timer1.Enabled = false;

    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <asp:Timer ID="Timer1" OnTick="Timer1_Tick" runat="server" Interval="10000" />

        <asp:UpdatePanel ID="StockPricePanel" runat="server" UpdateMode="Conditional">
            <asp:AsyncPostBackTrigger ControlID="Timer1" />
            Stock price is <asp:Label id="StockPrice" runat="server"></asp:Label><BR />
            as of <asp:Label id="TimeOfPrice" runat="server"></asp:Label>  
            <br />

        <br />
        Update stock price every:<br />
        <asp:RadioButton ID="RadioButton1" AutoPostBack="true" GroupName="TimerFrequency" runat="server" Text="10 seconds" OnCheckedChanged="RadioButton1_CheckedChanged" /><br />
        <asp:RadioButton ID="RadioButton2" AutoPostBack="true" GroupName="TimerFrequency" runat="server" Text="60 seconds" OnCheckedChanged="RadioButton2_CheckedChanged" /><br />
        <asp:RadioButton ID="RadioButton3" AutoPostBack="true" GroupName="TimerFrequency" runat="server" Text="Never" OnCheckedChanged="RadioButton3_CheckedChanged" />
        <br />
        Page loaded at <asp:Label ID="OriginalTime" runat="server"></asp:Label>

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5