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

RadWindow close error on second display

1 Answer 78 Views
Window
This is a migrated thread and some comments may be shown as answers.
Emil
Top achievements
Rank 2
Emil asked on 10 Feb 2013, 12:41 PM
Hello,

I have a project that basically looks like this:
  • Default.aspx - the page from which all activity begins
  • Vendors.aspx - a page displayed in a RadWindow opened from Default.aspx
  • VendorDetails.aspx - a page displayed in a RadWindow opened from Vendors.aspx which is used to add/edit a vendor.

When I open for the first time the Vendors window from Default.aspx and do some add/edit operation using the VendorDetails window (close/open several times), there is no problem. After I close the Vendors window, then open it again from Default.aspx, then open the VendorDetails, the first time I close the VendorDetails window, I get an error: Microsoft JScript runtime error: Can't execute code from a freed script.

I'm displaying the VendorDetails using Javascript:

var parentRadWindowManager = GetRadWindow().BrowserWindow.GetRadWindowManager();
var oWnd2 = parentRadWindowManager.open("VendorDetails.aspx?VendorID=0", "rwAddNewVendor");
   window.setTimeout(function () {
      oWnd2.set_title("Add new vendor");
      oWnd2.setActive(true);
      oWnd2.set_modal(true);
      oWnd2.setSize(800, 420);
      oWnd2.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Close);
      oWnd2.set_visibleStatusbar(false);
      oWnd2.set_showContentDuringLoad(false);
      oWnd2.center();
      oWnd2.add_close(RefreshGrids);
   }, 0);
return false;

I suspect the problem is in the VendorDetails.aspx RadWindow. This window contains the following Javascript:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
   <script type="text/javascript">
       function GetRadWindow() {
           var oWindow = null; if (window.radWindow)
           oWindow = window.radWindow; else if (window.frameElement.radWindow)
           oWindow = window.frameElement.radWindow; return oWindow;
       }
 
       function windowClose() {
           var oWindow = GetRadWindow();
           oWindow.showConfirm = false;
           oWindow.argument = null;
           oWindow.close();
           return false;
       }
   </script>
</telerik:RadCodeBlock>

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 11 Feb 2013, 02:00 PM
Hi Emil,

Generally you should not add handlers in the context of the content pages. The RadWIndow object lives in the context of the Default.aspx page and therefore all handlers must be attached there and this is where their declarations must be. In your case it seems the RefreshGrids function is in a content page instead of in the main page.

What I can suggest is the following:
- call a function in the main page that will open the popup, set its settings and add the close handler. See how to do this here - if you need information you can pass it as an argument
- the close handler (declared in the main page) can use the same approach to call the  RefreshGrids  in a content page if needed, or the  RefreshGrids  function may already reside in the Default page if this is where it is needed.
- you can also try removing the DestoyOnClose property because it is also a very likely reason for the error you get - the iframe where your handler is is already disposes when an attempt is made to execute RefreshGrids, so it is no longer available.


Kind regards,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Window
Asked by
Emil
Top achievements
Rank 2
Answers by
Marin Bratanov
Telerik team
Share this question
or