RadWindow close error on second display

2 posts, 0 answers
  1. Emil
    Emil avatar
    19 posts
    Member since:
    Oct 2012

    Posted 10 Feb 2013 Link to this post


    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.setSize(800, 420);
          oWnd2.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Close);
       }, 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;
               return false;
  2. Marin Bratanov
    Marin Bratanov avatar
    3907 posts

    Posted 11 Feb 2013 Link to this post

    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.
Back to Top