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

Decorated DropDownList firing window.onbeforeunload on IE

3 Answers 31 Views
FormDecorator
This is a migrated thread and some comments may be shown as answers.
HCT-CERT
Top achievements
Rank 1
HCT-CERT asked on 26 Aug 2013, 08:39 AM
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

3 Answers, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 27 Aug 2013, 02:52 PM
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.
0
Luke
Top achievements
Rank 1
answered on 21 Nov 2013, 05:16 PM
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.
0
Niko
Telerik team
answered on 26 Nov 2013, 10:19 AM
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.
Tags
FormDecorator
Asked by
HCT-CERT
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Luke
Top achievements
Rank 1
Niko
Telerik team
Share this question
or