I have a RadWindow with a page inside of it. There is a javascript function on this page which (using RadAjaxManager) asynchronously updates another control every 10 seconds. It does this through calling setTimeout on itself every time it fires. This is working the way I want it to. The problem is that once I close the window the javascript function is still firing every 10 seconds calling the the ajax postback.
I want to be able to cancel the timeout when the window is closed but I have no idea how to detect that event from the page inside the window. Any help?
All of this code is in the page that is contained in the radwindow
Javascript:
AjaxManager
Controls
Every 10 seconds the javascript fires the RefreshButton onclick event which refreshes the ListBox. When the window is closed I want to run some javascript like clearTimeout(updatingComments); which will stop the javascript from firing when the window is closed.
On an unrelated note, but still something that's bothering me, When I added the ListBox into the UpdatedControls on the AjaxManager the height=100% attribute of the list box stops working. Whats the best way around this? Thanks for any help.
I want to be able to cancel the timeout when the window is closed but I have no idea how to detect that event from the page inside the window. Any help?
All of this code is in the page that is contained in the radwindow
Javascript:
| <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"> |
| <script language="javascript" type="text/javascript"> |
| function UpdateComments() { |
| var ajaxManager = $find("<%= WorkbinItemAjaxManager.ClientID%>"); |
| ajaxManager.ajaxRequestWithTarget('<%= RefreshListBttn.UniqueID%>', ''); |
| updatingComments = setTimeout ( "UpdateComments()", 10000 ); |
| } |
| var updatingComments = setTimeout ( "UpdateComments()", 10000 ); |
| </script> |
| </telerik:RadScriptBlock> |
AjaxManager
| <telerik:RadAjaxManager ID="WorkbinItemAjaxManager" runat="server"> |
| <AjaxSettings> |
| <telerik:AjaxSetting AjaxControlID="RefreshListBttn"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="CommentsListBox" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| <telerik:AjaxSetting AjaxControlID="InsertCommentBttn" > |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="NewComment" /> |
| <telerik:AjaxUpdatedControl ControlID="CommentsListBox" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| </AjaxSettings> |
| </telerik:RadAjaxManager> |
Controls
| <asp:TextBox ID="NewComment" runat="server" TextMode="MultiLine" EmptyMessage="Add Comment Here..." |
| Rows="3" Width="95%" style="margin-top:5px;" /> |
| <asp:Button ID="InsertCommentBttn" runat="server" Text="Add Comment" OnClick="InsertComment" /> |
| <asp:Button ID="RefreshListBttn" runat="server" Text="Refresh List" OnClick="RefreshList" /> |
| <telerik:RadListBox ID="RadListBox1" runat="server" Height="100%" Width="100%" |
| DataSourceID="CommentsDataSource" DataKeyField="Comment_ID" OnItemDataBound="Comments_ItemDataBound" > |
| </telerik:RadListBox> |
Every 10 seconds the javascript fires the RefreshButton onclick event which refreshes the ListBox. When the window is closed I want to run some javascript like clearTimeout(updatingComments); which will stop the javascript from firing when the window is closed.
On an unrelated note, but still something that's bothering me, When I added the ListBox into the UpdatedControls on the AjaxManager the height=100% attribute of the list box stops working. Whats the best way around this? Thanks for any help.