Timer in Ajax Tool Kit

Using ajax tool kit then work as below code You got timer:

ASPX

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

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

        <asp:Timer runat="server" id="UpdateTimer" interval="1000" ontick="UpdateTimer_Tick" />

        <asp:UpdatePanel runat="server" id="TimedPanel" updatemode="Conditional">

            <Triggers>

                <asp:AsyncPostBackTrigger controlid="UpdateTimer" eventname="Tick" />

            </Triggers>

            <ContentTemplate>

                <asp:Label runat="server" id="DateStampLabel" />

            </ContentTemplate>

        </asp:UpdatePanel>

    </form>

Aspx.cs
 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

 

namespace WebApplication1

{

    public partial class _4 : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {


        }

        protected void UpdateTimer_Tick(object sender, EventArgs e)

        {

            DateStampLabel.Text = DateTime.Now.ToString();

        }

    }

}
 

X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now