My problem is after I click a button in update panel and close the window, "beforeunload" event not fire, while when I click another button this event fires properly. Here is my code:
function dontlogout() //for postback refreshes
{
postback = true;
alert(postback);
}
$(window).bind('beforeunload',function() {
if(postback==false)
{
//my logout code here;
}
else
{
postback = false;
}
});
<asp:Button runat="server" ID="cmdOut" OnClientClick="dontlogout();" Text="next" OnClick="cmdOut_Click"></asp:Button>
<asp:UpdatePanel runat="server" ID="updQuestion" >
<ContentTemplate>
<asp:Button runat="server" ID="cmdNext" OnClientClick="dontlogout();" Text="next" OnClick="cmdNext_Click"></asp:Button>
</ContentTemplate></asp:UpdatePanel>
when i click cmdOut button no problem and when close browser my log out code executed, but when i click cmdNext in update panel and then close the browser my log out code not executed.
How can I solve this problem?