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

Can't close window after maximizing it in ie.

1 Answer 56 Views
Window
This is a migrated thread and some comments may be shown as answers.
Darren
Top achievements
Rank 1
Darren asked on 10 Oct 2011, 04:22 AM
Hi,

I have a problem in ie where after maximizing the window and the trying to close it, the window returns to its original size and poistion and loses the close and maximize buttons?

The window loads a web page after selecting an option from a context menu, no issue in Firefox or Chrome.

Error below
Line: 2359
Error: 'sender._popupBehavior' is null or not an object

Thanks
Darren

 

<telerik:RadWindowManager ID="RadWindowManager" runat="server" OnClientClose="RadWindowManager_RadWindowClosing" 
  OnClientBeforeClose="RadWindowManager_BeforeClose" OnClientCommand="OnClientCommand" 
  OnClientResizeStart="OnClientStart" OnClientDragStart="OnClientStart" OnClientResizeEnd="OnClientEnd" 
  OnClientDragEnd="OnClientEnd" >
  <Windows>
     <telerik:RadWindow ID="LornRadWindow" runat="server"  Title="LORN" ShowContentDuringLoad="false"/>
     <telerik:RadWindow ID="ToolboxesRadWindow" runat="server" Title="Toolboxes" ShowContentDuringLoad="false"/>
     <telerik:RadWindow ID="WestOnePcRadWindow" runat="server" Title="WestOne Product Catalog" ShowContentDuringLoad="false"/>
  </telerik:RadWindowManager>

<telerik:RadScriptBlock ID="RadScriptBlock" runat="server">
        <script type="text/javascript">
            Telerik.Web.UI.RadWindowManager.prototype.cascade = function () {
                var radWindowArray = this._getWindowsSortedByZindex();
                var first = true;
                var top = 0;
                var left = 0;
  
                for (var i = 0; i < radWindowArray.length; i++) {
                    var radWindow = radWindowArray[i];
  
                    if (radWindow.isVisible() && !radWindow.isClosed()) {
                        if (first) {
                            //-- Store the location of the first window (all child windows will be cascaded from this location).
                            var bounds = radWindow.getWindowBounds();
                            left = bounds.x;
                            top = bounds.y;
                            first = false;
                        }
                        else {
                            //-- Offset the child window.
                            top += 30;
                            left += 30;
                            radWindow.moveTo(left, top);
                        }
                    }
                }
            };
  
            var lastOpenWindow;
            function RadWindowManager_RadWindowClosing() {
                // IE issue with auto focus on windows - only occurs with ASRI windows - set focus to student text box.
                // Limit other unknown issues by just fixing windows with issue.
                // for more information. - relates to system incident 38832
                if($telerik.isIE8 || $telerik.isIE7) {
                    if (lastOpenWindow == "MaintainAppointmentsRadWindow" || lastOpenWindow == "TrainingContractAppointmentsRadWindow" || lastOpenWindow == "ShowAppointmentsRadWindow" || lastOpenWindow == "ShowPAMeetingsRadWindow" || lastOpenWindow == "StudentResultsRadWindow") {
                        var oManager = GetRadWindowManager();
                        if (oManager) {
                            var oWindow = oManager.GetActiveWindow();
                            if (!oWindow) {
                                var textBoxes = document.getElementsByTagName("input");
                                if (textBoxes) {
                                    for (var tb = 0; tb < textBoxes.length; tb++) {
                                        try {
                                            textBoxes(tb).focus();
                                            break;
                                        }
                                        catch(er)
                                        {
                                            continue;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
  
            function RadWindowManager_BeforeClose() {
                if ($telerik.isIE8 || $telerik.isIE7) {
                    var oManager = GetRadWindowManager();
                    if (oManager) {
                        var oWindow = oManager.GetActiveWindow();
                        if (oWindow) {
                            lastOpenWindow = oWindow.get_name();
                        }
                    }
                }
            }
  
            // IMPORTANT - DO NOT REMOVE OR CHANGE THE FUNCTIONS BELOW
            //             THE FUNCTIONS ARE USED AS A WORKAROUND FOR RADWINDOWS THAT CONTAIN <OBJECT> TAGS E.G. SILVERLIGHT APPS
            //             IT STOPS THE SILVERLIGHT APP FROM RELOADING WHEN THE PAGE IS MOVED OR RESIZED. 
            ///            THIS WORKAROUND WAS PROVIDED BY TELERIK IN RESPONSE TO A SUPPORT REQUEST
  
            function OnClientCommand(sender, args) {
                args.set_cancel(true);
                sender._popupBehavior._manageVisibility = false;
  
                args.set_cancel(false);
                setTimeout(function () {
                    sender._popupBehavior._manageVisibility = true;
                }, 200);
            }
            function OnClientStart(sender, args) {
                sender._popupBehavior._manageVisibility = false;
            }
            function OnClientEnd(sender, args) {
                setTimeout(function () {
                    sender._popupBehavior._manageVisibility = true;
                }, 200);
            }
  
            Telerik.Web.UI.RadWindow.prototype._enablePageScrolling = function () {
            }
        </script>
    </telerik:RadScriptBlock>

1 Answer, 1 is accepted

Sort by
0
Darren
Top achievements
Rank 1
answered on 12 Oct 2011, 02:06 AM
Adding the below code resolved this problem.

The only case where I have seen similar behavior is when a version prior to Q1 2011 is used with IE9 - IE9 introduced a breaking change in the way iframes are created and handled and therefore versions of the RadControls for ASP.NET AJAX that have been released before the IE9 release do not support this browser. If you are using an older version you probably get a DOM exception error (5) when you open the RadWIndow initially. If so - please upgrade to the latest version (currently 2011.2.915 - Q2 2011 SP1) and see if the issue persists.

There is, however, one omission in the way the OnClientCommand event is handled - the popup behavior modifications need only be done if the command is not close:
functionOnClientCommand(sender, args)
{
    if(!args.get_commandName() == "Close")
    
        args.set_cancel(true);
        sender._popupBehavior._manageVisibility = false;
 
        args.set_cancel(false);
        setTimeout(function()
        {
            sender._popupBehavior._manageVisibility = true;
        }, 200);
    }
}
The original code would, indeed, prevent the RadWindow from closing, yet it should not result in an error.

If you are still experiencing difficulties please modify this test page so that it reproduces the described behavior reliably and send it back to me so I can debug it and see what is going on. A screen capture or detailed instructions showing how you recreate the error would also be helpful.

All the best,
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
Tags
Window
Asked by
Darren
Top achievements
Rank 1
Answers by
Darren
Top achievements
Rank 1
Share this question
or