Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q2 2011 released 07/12/2011
select

Ajax / Ajaxify Timer

Configurator
Change Timer Interval:
Timer interval: 3000
IndexValueChange 
Composite$7,522.00228.00 % decrease
Energy$8,605.0027.00 % decrease
Financial$7,122.00-30.00 % decrease
Health care$5,994.0048.00 % decrease

  • Although there is no "AJAX Timer" control in the ASP.NET AJAX suite opposite to the "Classic" RadAjax for ASP.NET, the "Classic" RadAjaxTimer still can be used with the new RadAjax framework.

    The example here illustrates how to AJAXify the standard MS Timer control with RadAjaxManager. There is a bit tricky part here -- one cannot add the Timer control directly to the AJAX settings as updated control. Instead, just wrap the timer in a container like ASP:Panel and set the container as updated control.

    The example also demonstrates continuous update of RadGrid per certain interval. This however can be achieved by binding the Grid client or server-side through Web Service. See demos in the Related Resources tab.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="telerik" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <%@ Register TagPrefix="telerik" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="telerik" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>

    <%@ Page Language="c#" CodeFile="DefaultCS.aspx.cs" AutoEventWireup="false" Inherits="Telerik.AJAXExamplesCSharp.AJAX.Examples.Common.AjaxifyTimer.DefaultCS" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/tr/xhtml11/DTD/xhtml11.dtd">
    <html xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <telerik:HeadTag ID="Headtag1" runat="server"></telerik:HeadTag>
    </head>
    <body class="BODY">
        <form runat="server" id="mainForm">
        <telerik:Header runat="server" ID="Header1" NavigationLanguage="CS" XhtmlCompliant="false">
        </telerik:Header>
        <!-- content start -->
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="Timer1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="LoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="DropDownList1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="Panel1" />
                        <telerik:AjaxUpdatedControl ControlID="Panel2" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="LoadingPanel1" runat="server" />
        <qsf:ConfiguratorPanel runat="server" ID="ConfigurationPanel1" Title="Configurator"
            Expanded="true">
            <table>
                <tr>
                    <td style="width: 250px">
                        Change Timer Interval:
                        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
                            <asp:ListItem Text="2 seconds" Value="2000"></asp:ListItem>
                            <asp:ListItem Text="3 seconds" Value="3000" Selected="True"></asp:ListItem>
                            <asp:ListItem Text="5 seconds" Value="5000"></asp:ListItem>
                        </asp:DropDownList>
                    </td>
                    <td>
                        <asp:Panel ID="Panel2" runat="server">
                            Timer interval:
                            <asp:Label ID="lblInterval" runat="server" Text="3000" Style="font-weight: bold;"></asp:Label>
                        </asp:Panel>
                    </td>
                </tr>
            </table>
        </qsf:ConfiguratorPanel>
        <div style="float: left;">
            <telerik:RadGrid ID="RadGrid1" runat="server" Width="400px" OnItemDataBound="RadGrid1_ItemDataBound"
                OnNeedDataSource="RadGrid1_NeedDataSource">
                <MasterTableView AutoGenerateColumns="False" DataKeyNames="Change" TableLayout="Fixed">
                    <Columns>
                        <telerik:GridBoundColumn DataField="Index" HeaderText="Index" UniqueName="Index">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Value" HeaderText="Value" DataFormatString="{0:C2}"
                            UniqueName="Value">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Change" HeaderText="Change" DataFormatString="{0:P2}"
                            UniqueName="Change">
                        </telerik:GridBoundColumn>
                        <telerik:GridTemplateColumn UniqueName="TemplateColumn">
                            <HeaderStyle Width="40px" />
                            <ItemTemplate>
                                <asp:Image ID="Image1" AlternateText="progress" BorderWidth="0px" runat="server">
                                </asp:Image>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>
        </div>
        <asp:Panel ID="Panel1" runat="server">
            <asp:Timer ID="Timer1" runat="server" Interval="3000" OnTick="Timer1_Tick" />
        </asp:Panel>
        <!-- content end -->
        <telerik:Footer runat="server" ID="Footer1"></telerik:Footer>
        </form>
    </body>
    </html>

Get more than expected!

 
 

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2024 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451