I want to catch event when user close page.
-
I want to catch event when user close page. And i expect to work just one time. So i Write blow but it does work when page load. How can i catch event? protected void Page_UnLoad(object sender, EventArgs e) { }
hi My english is a little. anyway, nice to meet you~~ and give me your advice anytime~
-
I want to catch event when user close page. And i expect to work just one time. So i Write blow but it does work when page load. How can i catch event? protected void Page_UnLoad(object sender, EventArgs e) { }
hi My english is a little. anyway, nice to meet you~~ and give me your advice anytime~
you can use this to catch close event for the page using this. < body onbeforeunload="alert('Closing');">
-
you can use this to catch close event for the page using this. < body onbeforeunload="alert('Closing');">
Function < body önbeforeunload="alert('Closing');"> is also working when I click other button(which make refresh page). I want to execute .cs fuction when user close page or move other page. Thank you!
hi My english is a little. anyway, nice to meet you~~ and give me your advice anytime~
-
Function < body önbeforeunload="alert('Closing');"> is also working when I click other button(which make refresh page). I want to execute .cs fuction when user close page or move other page. Thank you!
hi My english is a little. anyway, nice to meet you~~ and give me your advice anytime~
With the help of Jquery you can call code behind function somthing like this HTML Part: <script src="jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> function confirmSubmit() { $.ajax({ url: '/WebSite2/Default.aspx/SecretFormula', type: 'POST', contentType: 'application/json', data: '{}', success: function(result) { alert(result.d); } }); alert("I am in "); } </script> </head> <body onbeforeunload="confirmSubmit()"> <form id="form1" runat="server">
</form> </body> </html> Code Behind Function:
** _**
Public Shared Function SecretFormula() As Integer Return 42 End Function