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

"Sys is undefined" on Close

14 Answers 220 Views
Window
This is a migrated thread and some comments may be shown as answers.
Serhat Gülmez
Top achievements
Rank 1
Serhat Gülmez asked on 20 Jul 2011, 12:07 PM

We have upgraded to version 712 and now we do receive the  'Sys' is undefined error everytime the close method of radwindow is called. The window gets closed; and after that the error is raised.

Below is the code we use with all previous versions (v < 712) of ASP.NET Ajax:

//----------------------------------------

function GetRadWindow()
{
    var oWindow = null;
    if (window.radWindow) oWindow = window.radWindow;
    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
    return oWindow;
}

var oWnd = GetRadWindow();
if (oWnd) oWnd.close();
//----------------------------------------

Please let us know what to do ASAP.

Thanks.

14 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 21 Jul 2011, 11:55 AM
Hi Abdurrahman,

  This is the first time such an issue has been reported, and especially after the upgrade. I tested your code with Q2 2011: http://screencast.com/t/qpggo35hYg and with an older version Q1 2011: http://screencast.com/t/CQksTz3YG8O with the same results. You can find my test page attached as a reference. Please make sure that you do not have any other JavaScript errors on the page or some other modification in your code is causing this behavior.


Regards,
Marin
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Rob Wade
Top achievements
Rank 1
answered on 26 Jul 2011, 10:54 PM
I just updated also and get the same error Sys is undefined on all popup windows that I close using server side code:


ScriptManager.RegisterStartupScript(
this.Page, this.Page.GetType(), "KEY", "CancelEdit();", true);

0
Marin Bratanov
Telerik team
answered on 28 Jul 2011, 11:37 AM
Hi guys,

Yesterday this issue was reported with some more details and a project that reproduced it reliably. After investigating the issue we have come to the following conclusion:


In case you inject the script from the code behind an issue with the iframe disposal under IE9 presents itself. This issue stems from the way IE9 handles (and more specifically - disposes) iframes. The lifecycle under this browser is different and the iframe actually does not dispose properly. We have done some things to alleviate this issue, but we have not been able to resolve it for some scenarios, as a fix for this sometimes breaks another functionality. We are aware of this and if a viable solution is found it will be incorporated in the RadWindow code.

In the meantime you can use a simple workaround that will not affect the performance and functioanlity of your page:
setTimeout(function () 
    
        GetRadWindow().close(); 
    }, 0);

This happens when only when the DestroyOnClose property is set to true, so if you do not need it I would advise that you remove it.


 All the best,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
O.D.
Top achievements
Rank 1
answered on 23 Nov 2011, 06:24 PM
Hi,

Thanks Marin, 

The fix worked for me, as of Today 23/11/2011 :)

Kind Regards,
O.D.
0
Ivan Queiroz
Top achievements
Rank 1
answered on 29 Feb 2012, 06:17 PM
I still have this same exact problem with V 2012.1.215.40 of the control.

As Marin mentions above, it only happens with IE 9. However, if I use IE 7 compatibility, it works fine, but this is not what we want to do.

I tried removing DestroyOnClose="true," which does get rid of the error,  but breaks our functionality.

Any other suggestion on how to deal with this?

Thanks.

* BTW, I also tried using:

setTimeout(function () 
    
        GetRadWindow().close(); 
    }, 0);

along with
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 as well)
 
             return oWindow;
         }

The a problem with the above is that "window.frameElement" is null the first time the page is loaded.
0
Marin Bratanov
Telerik team
answered on 02 Mar 2012, 10:27 AM
Hello Ivan,

Can you confirm you are using the XHTML 1.0 Transitional doctype? If not please give it a try and see if it helps. Having the frameElement property return null is quite unexpected and I am not certain what could be causing it. You can also examine this thread that discusses a similar issue and offers two suggestions on getting around it. Since the original poster never got back to us I cannot confirm if a reason has been found or the suggestions worked for that case.


Greetings,
Marin
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.
0
Ivan Queiroz
Top achievements
Rank 1
answered on 02 Mar 2012, 03:04 PM
Marin,

I am using <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">.  I also tried the HTML5 doctype (which we will start using in the very near future) and <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> .

I have the same issue with all of the above.

I do have a very simply project that you can use to reproduce this issue. However, since I can't attach it here, I'll submit a ticket.

Thanks for your help.

Ivan
0
Marin Bratanov
Telerik team
answered on 06 Mar 2012, 10:05 AM
Hi Ivan,

I have examined the project from the support ticket and I believe the issue in it was the one described in one of my earlier posts - with the Sys is undefined error and the resolution is also the same. I am writing this here since I have not received further replies from you in the ticket and I decided to provide this information to someone else that may be looking at a similar scenario.


Greetings,
Marin
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.
0
Ivan Queiroz
Top achievements
Rank 1
answered on 06 Mar 2012, 01:48 PM
Hi Marin,

Yes, your solution does work.

Thank you so much. I do appreciate your help.

Ivan
0
Karen
Top achievements
Rank 1
answered on 19 Jun 2012, 08:51 AM
Hello Marin,

I'm using version 2011.3.1115.40 and am experiencing the same problem as reported in this ticket. Can you let me know if a later release of ASP.NET AJAX includes a fix for this issue with IE 9?

Thanks.
0
Marin Bratanov
Telerik team
answered on 20 Jun 2012, 10:33 AM
Hi Karen,

As one of my first posts explains - this problem stems from a buggy behavior in IE9 related to iframe disposal and therefore we cannot fix this, because it stems from the browser code and not from our. Simply said - not all browser bugs can have a workaround in our code and this is one of them.

This means that either removing DestroyOnClose or using the timeout is the way to work around this scenario.

Even though this exact problem cannot be fixed there have been numerous other fixes (including ones for IE9 specific problems) in the latest releases, so I would advise that you upgrade to the latest version (Q2 2012) to benefit from them and from the new features and controls that are added to the suite.


All the best,
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.
0
Juan
Top achievements
Rank 1
answered on 09 May 2014, 04:43 PM
Hi, we have been using the RadWindow/RadWindowManager for a few years without problems, in the past (not often) we had this error, but since december start to be a big issue in our application.
We register the call to the close script in the codebehind. The strange situation is that this happen sometimes without any pattern just randomly.
I will start to try to implement some workaround, but I want to know if maybe updating versión may help us.
Telerik.Web.UI.dll -> 2014.1.225.40

The events order is:

1- from a Iframe we call this script to open de Window:
// Abre un RadWindow o WindowManager
function openWinSec(url, idWin, WinManager, w, h, prevent_close, ajax_call) {
var win = null;

if (WinManager) {
var win = $find("<%= winSec.ClientID %>");
win.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move);
win.set_title("");
win.setUrl(url);
win.setSize(w, h);

if (prevent_close == true) {
win.add_beforeClose(ajax_call);
}

win.show();
}
else {
var win = $find("<%= winSec.ClientID %>");
win.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move);
win.set_title("");
win.setUrl(url);
win.show();
}
}

2 - After the user end the work, the form make a postback and in the codebehind the call to the function for close the window is inserted in the page using one instance of RadAjaxManager.ResponseScripts.Add("CloseWin('actGrillaActividades');");

The close window function:
function GetRadWindow() {
var oWindow = null;
if (window.radWindow)
oWindow = window.radWindow;
else if (window.frameElement.radWindow)
oWindow = window.frameElement.radWindow;

return oWindow;
}

function CloseWin(prm) {
var oWnd = GetRadWindow();
oWnd.BrowserWindow.RefreshPage(prm); <- Refresh Iframe who initiate the operation
oWnd.Close();
}




Thanks in advance...
JP
0
Marin Bratanov
Telerik team
answered on 10 May 2014, 03:41 PM

Hi JP,

Have you tried adding a timeout, as previously suggested at the beginning of the thread?

function CloseWin(prm) {
 var oWnd = GetRadWindow();
 oWnd.BrowserWindow.RefreshPage(prm); //<- Refresh Iframe who initiate the operation
 setTimeout(function() {
    oWnd.close();
 }, 0);
 }

The other things you should take a look at are:

  • such an error is most common if DestroyOnClose is set to true. If this is not needed by your logic (e.g., the same RadWindow can be reused because it opens the same page), you can remove it.
  • make sure that the handler added through add_close() has the same context as the RadWindow that is opened. You should avoid having the handler come from another frame (e.g., the frame that calls the opening function) but the RadWindow itself being in another (e.g., parent) frame.

I hope this helps.


Regards,

Marin Bratanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Juan
Top achievements
Rank 1
answered on 12 May 2014, 12:27 PM
Hi Marin, thanks for the reply.

Yes I try this workaorund and Works!, but doesn't work for all versions of IE (still fail on IE11), I will start a deep analisys about how this process is do it.

I will let you know.
Tags
Window
Asked by
Serhat Gülmez
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Rob Wade
Top achievements
Rank 1
O.D.
Top achievements
Rank 1
Ivan Queiroz
Top achievements
Rank 1
Karen
Top achievements
Rank 1
Juan
Top achievements
Rank 1
Share this question
or