Start/Stop Ajax Timer when Window Shows/Closes

2 posts, 0 answers
  1. Jerry Jansen
    Jerry Jansen avatar
    47 posts
    Member since:
    Aug 2009

    Posted 01 Mar 2010 Link to this post

    I have a master/content page with the timer, window, and the code below all in the content page. I am trying to stop the ajax timer when the window shows and then start the timer when the window closes. The windows opens and closes fine.

    The problem is that I get a javascript error on the _startTimer() and _stopTimer() functions:

    Error: Object doesn't support this property or method

    How can I stop and restart the ajax timer?

    Window code:
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="Web20" Width="500"
            Height="300" VisibleStatusbar="False" ReloadOnShow="True" ShowContentDuringLoad="False"
            DestroyOnClose="True" EnableViewState="False" Modal="True" OnClientClose="enableTimer()"
                <telerik:RadWindow runat="server" Left="" NavigateUrl="ShowAmendments.aspx" Style="display: none;"
                    Top="" ID="rwShowAmendments" Title="Amendments Information" VisibleStatusbar="False"
                    InitialBehaviors="None" Modal="True">

    Timer and javascript code:
        <asp:Panel ID="Panel1" runat="server">
            <asp:timer id="Timer1" runat="server" interval="8000" ontick="Timer1_Tick" />
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script language="javascript" type="text/javascript">
                function openRadWindowAmendments(Measure) {
                    var oWnd = radopen("ShowAmendments.aspx?Measure=" + Measure, "rwShowAmendment");
                    var TitleBar = oWnd.GetTitlebar();
                    var parent = TitleBar.parentNode;

                    var oUL = parent.getElementsByTagName('UL')[0];
                    // = "192px";

                    var li = document.createElement("LI");
                    var a = document.createElement("A");
                    a.className = "custombutton";
                    a.title = "Print Content";
                    a.onmousedown = printWin;

                    oUL.insertBefore(li, oUL.firstChild);

                function printWin(e) {
                    var oManager = GetRadWindowManager();
                    var oWnd = oManager.GetWindowByName("rwShowFloorCalendar");
                    var content = oWnd.GetContentFrame().contentWindow;
                    var printDocument = content.document;
                    if (document.all) {
                    else {

                    //Cancel event!
                    if (!e) e = window.event;

                    return $telerik.cancelRawEvent(e);

            <script type="text/javascript" src="scrollsaver.min.js"></script>
        <script type="text/javascript">

            function disableTimer() {
                var t = document.getElementById("<%=Timer1.ClientID%>");
                if (t != null) {

            function enableTimer() {
                var t = document.getElementById("<%=Timer1.ClientID%>");
                if (t != null) {


  2. Georgi Tunev
    Georgi Tunev avatar
    7207 posts

    Posted 04 Mar 2010 Link to this post

    Hello Jerry,

    This issue is not directly related to the RadWindow control - you will experience the same error if you remove the RadWindow from the page and call your JS code by clicking on a standard button.
    The reason for the problem is the way you try to access the timer - by using document.getElementByID. You should use $find instead:

    $find("<%=Timer1.ClientID %>");

    Georgi Tunev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft R3 2016 release webinar banner
Back to Top