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

Problem with document.selection.empty() when moving RadWindow

7 Answers 190 Views
Window
This is a migrated thread and some comments may be shown as answers.
Mink
Top achievements
Rank 1
Mink asked on 27 Nov 2009, 04:08 PM
Hi,

I bumped into a rather obscure problem when using RadWindow.
The problematic situation rises under the following circumstances:
An input field with selected content has style.display="none" on the same page as the RadWindow is shown. Then try to move or resize the window. An Unknown Runtime Error occurs in the Telerik script at the point where document.selection.empty() is called.
From DOM perspective I can imagine that emptying the selection on a non-visible element is problematic, but I think the Telerik script should anticipate such a situation and act accordingly instead of letting an error occur.

I can imagine it might come across as a weird situation having a hidden input field with selected content (on the same page as a RadWindow) so let me explain the situation I encountered the problem:
I have a edit form with a tab strip combined with a multi page. On the first tab the first input is selected and given focus so that the user can start altering the data easily. On the second tab there is a button which causes a RadWindow to appear as a modal dialogue where the edited user can be linked to user groups. When I let the selected content on the first tab to remain selected when I switch to the second tab, click the button which causes the RadWindow to appear and then try to move or resize the RadWindow I get the Unknow Runtime Error on the line where document.selection.empty() is called.

While searching for the one exact cause of my problem I have created a situation as simple as possible which demonstrates the problem. For your convenience I will place it here:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MoveRadWindowTest.aspx.cs" Inherits="CMS.Views.Tests.MoveRadWindowTest" %> 
 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title></title
</head> 
 
<body> 
<form id="form1" runat="server"
    <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
     
    <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="OpenRadWindow();return false;" /> 
     
    <div id="HideMe"
        <asp:TextBox ID="TextBox1" runat="server" /> 
    </div> 
     
    <telerik:RadWindow ID="RadWindow1" runat="server" Modal="true" NavigateUrl="http://www.telerik.com" /> 
</form> 
     
    <script type="text/javascript"
        function OpenRadWindow() { 
            $get('HideMe').style.display = "none"
             
            $find("<%=RadWindow1.ClientID%>").show(); 
        } 
    </script> 
</body> 
</html> 
 

There is nothing custom in the code behind file.

I hope this problem can be fixed. (I expect a check whether the selected content is visible should be the way to go.)

Regards,

Mink

7 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 30 Nov 2009, 02:32 PM
Hello Mink,

I tried to reproduce the problem with the code that you sent me but everything is working as expected on my end - see attached video. I tried the code with IE and Firefox and also tried moving and resizing the browser window - still, I was not able to reproduce any problem. Could you please let me know if I am missing something?


Regards,
Georgi Tunev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Mink
Top achievements
Rank 1
answered on 01 Dec 2009, 07:21 AM
Hi Georgi,

Thanks for sending that video because I think I know what you missed: the problem only rises when there is text entered and selected in the texbox before clicking the button.
If that doesn't cause a problem at your end I'm stuck with a very unique problem on my end unfortunately.
So give it another try if you please.

Regards,

Mink

0
Georgi Tunev
Telerik team
answered on 01 Dec 2009, 11:22 AM
Hello Mink,

Thank you for the additional details - now I was able to reproduce the problem. It is IE-specific and occurs because you basically get a selected (focused) element that is being hidden. When you try to move / resize the window, the selection is lost, but because the focused element is hidden, the browser throws "uknown" error.

What I can suggest as a solution is to change the way you hide the DIV. You could either set its visibility to hidden, or as an alternative - to move the DIV outside of the viewport.
e.g.

function OpenRadWindow()
{
    $get('HideMe').style.position = "absolute";
    $get('HideMe').style.left = "-9999" + "px";
 
    $find("<%=RadWindow1.ClientID%>").show();
}


I hope this helps.

All the best,
Georgi Tunev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
James
Top achievements
Rank 1
answered on 04 May 2010, 04:12 PM
I have also had this problem but am not hiding anything on my webpage. Here is my failure:

,_onDragStart:

function(ev){

 

window._event=ev;

document.selection.empty();    <<<<<<<<

var

 

dt=ev.dataTransfer;

 

if

 

(!dt&&ev.rawEvent){

 

dt=ev.rawEvent.dataTransfer;

}

I am dragging a window that is on a RadAjaxPanel, the whole page is using a MasterPage. If I resize a window, then move it I have no problems. If I select a toolbar textbox (that is on the RadAjaxPanel) then attempt a move I get this error (and another error on dragend). I can select a combo-box and if I pick an item on the dropdown and move, it works. If I dropdown the list and attempt a move either while it is still dropped-down or while only selecting half a text item I get this error.

I have tried manually clearing the selection on OnClientDragStart event but something is re-selecting an object afterwards, assuming its the drag code. Can you suggest anything I can do before-hand to solve this? Most of the page is ajax-ified but in the mode when I allow window movement nothing is active, almost like a design mode.

The page itself has a lot of components so creating a test version of it would be difficult, and I'm sure a simple version with half as much code is bound to work :).

HELP! :)

 

0
James
Top achievements
Rank 1
answered on 04 May 2010, 04:58 PM
To add to this, it only happens in IE8, if I turn on compatability mode the problem goes away.
0
Lini
Telerik team
answered on 07 May 2010, 11:53 AM
Hello,

You should update to the current 2010 Q1 version of the RadControls for ASP.NET AJAX if possible, as the problem seems to be fixed there. If you don't want to update, you can add the following tag in the <head> section of your page, which will force IE to always be in compatibility mode so you will not see the problem:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

Best wishes,
Lini
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
James
Top achievements
Rank 1
answered on 07 May 2010, 11:57 AM
I am not able to update at present as we are very close to release. I had implemented this workaround already, luckily we have a masterpage so only 1 place required to fix.
Tags
Window
Asked by
Mink
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Mink
Top achievements
Rank 1
James
Top achievements
Rank 1
Lini
Telerik team
Share this question
or