Decorated DropDownList firing window.onbeforeunload on IE

4 posts, 0 answers
  1. HCT-CERT
    HCT-CERT avatar
    22 posts
    Member since:
    Aug 2012

    Posted 26 Aug 2013 Link to this post

    Hi,

    I have a decorated DropDownList, and when clicking it , it fires onbeforeunload though no item is selected yet.This is happening in IE while chrome works fine. Any idea on how to stop this as I am using form confirmation for saving changes before leaving the page.

    Environment:
    VS 2012
    ASP.NET 4.5
    Telerik Ajax Controls Q3 2012

    Thanks

    Madani
  2. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1490 posts

    Posted 27 Aug 2013 Link to this post

    Hi Madani,

    I have tried to reproduce the mentioned issue but to no avail. You can find a short video with the test in the attached archive and then tell me what I am missing.

    Could you please, try to reproduce the issue with the attached archive and then tell me what changes you have made, so that I can proceed further with the investigation?

    Regards,
    Danail Vasilev
    Telerik
    Explore the entire set of ASP.NET AJAX controls we offer here and browse the myriad online demos to learn more about the components and the features they incorporate.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Luke
    Luke avatar
    1 posts
    Member since:
    Nov 2013

    Posted 21 Nov 2013 Link to this post

    Danail - I am having the same issue with my project, and when using the code you supplied.  The onbeforeunload event appears to be firing when the decorated dropdown is opened.  In your example video you would only click the dropdown once to switch from text1 to text2 and then you would refresh the page.  Since the issue appears to be with opening the dropdown this will not reproduce the issue.  You can either remove the conditional for selectedindex != 0, or attempt selecting the dropdown multiple times and the "attempting to leave this page" dialog will appear.

    Experiencing this in IE8 & IE10.
  5. Niko
    Admin
    Niko avatar
    387 posts

    Posted 26 Nov 2013 Link to this post

    Hi,

    The issue is reproducible and I will make sure to log it in our backlog for fixing. It is due to the rendering of the decorated select element and the way IE misbehaves when working with anchor tags. Still there is a workaround that you can incorporate in the meantime. Make sure that the following script is part of the page:
    function pageLoad() {
        var select = $get("select"),
            decoration = Telerik.Web.UI.RadFormDecorator.getDecoratedElement(select);
     
        $telerik.addHandler(decoration, "click", preventDefault);
    }
     
    function preventDefault(e) {
        if(e.preventDefault) {
            e.preventDefault();
        }
        e.returnValue = false;
     
        return false;
    }

    This approach would prevent the select decoration from performing the default behavior, which in the case of the anchor tag is to leave the page, thus forcing the beforeunload.

    Hope this helps.

    Regards,
    Niko
    Telerik
    Explore the entire set of ASP.NET AJAX controls we offer here and browse the myriad online demos to learn more about the components and the features they incorporate.
Back to Top