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

8 posts, 0 answers
  1. Mink
    Mink avatar
    57 posts
    Member since:
    Apr 2009

    Posted 27 Nov 2009 Link to this post

    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
  2. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 30 Nov 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mink
    Mink avatar
    57 posts
    Member since:
    Apr 2009

    Posted 01 Dec 2009 Link to this post

    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

  5. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 01 Dec 2009 Link to this post

    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.
  6. James
    James avatar
    60 posts
    Member since:
    Sep 2007

    Posted 04 May 2010 Link to this post

    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! :)

     

  7. James
    James avatar
    60 posts
    Member since:
    Sep 2007

    Posted 04 May 2010 Link to this post

    To add to this, it only happens in IE8, if I turn on compatability mode the problem goes away.
  8. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 07 May 2010 Link to this post

    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.
  9. James
    James avatar
    60 posts
    Member since:
    Sep 2007

    Posted 07 May 2010 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017