ASP.Net AJAX Timer Control

by top54u.com 01 May, 2008

Introduction

AJAX Timer Control performs the partial or full page postback at the defined intervals. When AJAX Timer Control is placed inside the UpdatePanel then it enables the partial page postbacks at the defined intervals. AJAX Timer Control is a server control that includes the JavaScript component to enable the page postbacks at regular intervals to update the page content.

 

Using Timer Control inside an UpdatePanel Control

AJAX Timer Control consists of properties such as Enabled and Interval. You can enable or disable the Timer Control by setting the Enabled property True or False. Interval property of AJAX Timer Control defines the Time interval to perform any specific update task on the web page. Default value for Interval property is 60000 which is equal to 60 seconds coz Interval property takes the value in milliseconds. So, 60000 milliseconds are equal to 60 seconds.

 

Tick Event Handler of AJAX Timer Control handles the code for Timer Control to perform the content update on ASP.Net web page when partial or full page postback occurs after the specified intervals.

 

AJAX Timer Control Sample Code

Following Sample Code for Timer Control shows the use of AJAX Timer control to display the Digital Time Clock on web page the updates the time after every 1 second interval.

 

HTML Code for AJAX Timer Control:

 

<form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick">
                </asp:Timer>
                <asp:Label ID="lblTimer" runat="server"></asp:Label>
            </ContentTemplate>
        </asp:UpdatePanel>
   
    </div>
</form>

 

C# Code for AJAX Timer Control:

    protected void Timer1_Tick(object sender, EventArgs e)
    {
        lblTimer.Text = DateTime.Now.ToLongTimeString();
    }

Spotlight.....

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , , , ,

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

10/11/2008 3:27:37 AM




related videos.....
recent posts.....
top54u ezines.....