I'm attempting to capture the closing of a rad window and do a postback.
The scenario is this:
1) the RadWindowManager is in the master page with a method to pop the window:
I pop the window from a web control sitting on a page:
In the page hosted in the rad window (just a stand-alone page, no master page, etc.) I attach a close handler to cause a post-back:
In the postback I perform a save and then emit javascript to close the rad window:
Everything appears to work just fine, and does in fact work fine the first time. The second time I pop the window from the control, however, I get a javascript error:
Message: Can't execute code from a freed script
I've tried all combinations of add_close(), remove_close(), returning false from JS functions, etc. and I can't get it to work correctly. It seems a little counterintuitive to have to jump through all these hoops to get this functionality anyway, so perhaps there's better way to handle this.
Essentially I'm attempting to have the window perform a code-behind save when it's closed (without having to put a button on the page).
Any ideas?
Thanks
The scenario is this:
1) the RadWindowManager is in the master page with a method to pop the window:
<telerik:RadWindowManager ID="RadWindowManager1" runat="server"Skin="Office2007"KeepInScreenBounds="true"Behaviors="Move, Close"> <Windows> <telerik:RadWindow runat="server" ID="rwGeneral" AutoSize="true" Modal="true" Title="" OnClientPageLoad="OnClientPageLoad" /> </Windows> </telerik:RadWindowManager>function getRadWindow() { return $find('<%# rwGeneral.ClientID %>'); } function openRadWindow(url, Title) { var oWnd = getRadWindow(); if (Title) oWnd.set_title(Title); oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Resize) oWnd.setUrl(url); oWnd.show(); return false; }I pop the window from a web control sitting on a page:
function popBranchPicker() { var radWindow = getRadWindow(); radWindow.add_close(radWindow_OnClientClose); openRadWindow('<%= BranchPickerPopupUrl %>', 'Branch Picker'); return false; } function radWindow_OnClientClose(oWnd, args) { // clean up the close method var radWindow = getRadWindow(); radWindow.remove_close(radWindow_OnClientClose); // refresh here var btnRefresh = document.getElementById('<%= btnRefreshBMDashboardAndPicker.ClientID %>'); btnRefresh.click(); return false; } In the page hosted in the rad window (just a stand-alone page, no master page, etc.) I attach a close handler to cause a post-back:
GetRadWindow().add_close(doClose); function GetRadWindow() { var oWindow = null; if (window.radWindow) oWindow = window.radWindow; // Will work in Moz in all cases, including clasic dialog else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; // IE (and Moz az well) return oWindow; } function CloseOnReload() { GetRadWindow().Close(); } function doClose() { document.forms[0].submit(); } In the postback I perform a save and then emit javascript to close the rad window:
// some stuff here RadAjaxPanel1.ResponseScripts.Add("CloseOnReload();"); Everything appears to work just fine, and does in fact work fine the first time. The second time I pop the window from the control, however, I get a javascript error:
Message: Can't execute code from a freed script
I've tried all combinations of add_close(), remove_close(), returning false from JS functions, etc. and I can't get it to work correctly. It seems a little counterintuitive to have to jump through all these hoops to get this functionality anyway, so perhaps there's better way to handle this.
Essentially I'm attempting to have the window perform a code-behind save when it's closed (without having to put a button on the page).
Any ideas?
Thanks