Hi,
I'm using "window.onbeforeunload" in order to avoid a different page before saving some information. The problem is when i check or unchek any item in the wepdropdown because it invokes the "onbeforeunload" and i want to avoid this behavior
Hello julio486,
This "onbeforeupload" event will be fired each time when the page performs a Postback to the server, because the “Unload” event is part of the ASPX page Life Cycle - http://msdn.microsoft.com/en-us/library/ms178472.aspx
In order to prevent this you may try to avoid the selection of the "WebDropDown" items to make full Postbacks to the server by insering it in "UpdatePanel" or handle all the events in Client-Side.
More about usage of “onbeforeunload” event you can read here - http://msdn.microsoft.com/en-us/library/ms536907(v=vs.85).aspx
That's exactly how it's supposed to work, but it doesn't. I'm using Infragistics 2014.1 build 2150 in IE9. I have cascading dropdowns *inside* an UpdatePanel as following. When the first dropdown is selected, then the second populates correctly. Then the first time and only the first time that I change the value of the second dropdown the onbeforeunload is called. It's not called when I change the value the second time. It's seems like an IE9 issue. I haven't tried other IE versions. This doesn't happen in Chrome, but of course my target browser is IE9. Any suggestions?
<script type="text/javascript"> var dirty = false; var skipConfirm = false; var autoDestroyEligDate = true; window.onbeforeunload = confirmExit;
function confirmExit() { if (dirty && !skipConfirm) { return "You have attempted to leave this page without saving your changes."; } }
function SetDirtyFlag() { dirty = true; }
....
</script>
... <asp:UpdatePanel runat="server" ID="UpdatePanel1" ChildrenAsTriggers="False" UpdateMode="Conditional"> <Triggers> <asp:PostBackTrigger runat="server" ControlID="btnSave"/> <asp:PostBackTrigger runat="server" ControlID="btnReset"/> <asp:AsyncPostBackTrigger runat="server" ControlID="cmbDeptOwner" EventName="ValueChanged"/> </Triggers> <ContentTemplate>
<ig:WebDropDown ID="cmbDeptOwner" runat="server" BackColor="White" BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px" ForeColor="Black" Width="220px" DisplayMode="DropDownList" OnSelectionChanged="cmbDeptOwner_SelectionChanged"> <AutoPostBackFlags SelectionChanged="On" /> <ClientEvents SelectionChanging="ReturnTrueIfNotEditable" DropDownOpening="ReturnTrueIfNotEditable" SelectionChanged="SetDirtyFlag" /> </ig:WebDropDown>
.........
<ig:WebDropDown ID="cmbDescription" runat="server" BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px" Width="220px" ForeColor="Black" DisplayMode="DropDownList" CurrentValue=""> <ClientEvents SelectionChanged="SetDirtyFlag" /> </ig:WebDropDown>
.....
</ContentTemplate> </asp:UpdatePanel></asp:Content>