This is a migrated thread and some comments may be shown as answers.

Start/Stop Ajax Timer when Window Shows/Closes

1 Answer 123 Views
Window
This is a migrated thread and some comments may be shown as answers.
Jerry Jansen
Top achievements
Rank 1
Jerry Jansen asked on 01 Mar 2010, 05:07 PM
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?

Thanks!
------------------------------------------------------
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()"
        OnClientShow="disableTimer()">
        <Windows>
            <telerik:RadWindow runat="server" Left="" NavigateUrl="ShowAmendments.aspx" Style="display: none;"
                Top="" ID="rwShowAmendments" Title="Amendments Information" VisibleStatusbar="False"
                InitialBehaviors="None" Modal="True">
            </telerik:RadWindow>
        </Windows>
</telerik:RadWindowManager>

Timer and javascript code:
    <asp:Panel ID="Panel1" runat="server">
        <asp:timer id="Timer1" runat="server" interval="8000" ontick="Timer1_Tick" />
    </asp:Panel>
    <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];
                //oUL.style.width = "192px";

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

                oUL.insertBefore(li, oUL.firstChild);
                oWnd.center();
            }

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

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

                return $telerik.cancelRawEvent(e);
            }

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

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

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

    </script>
    </telerik:RadCodeBlock>







1 Answer, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 04 Mar 2010, 11:55 AM
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 %>");


Greetings,
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.
Tags
Window
Asked by
Jerry Jansen
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Share this question
or