Click here to Skip to main content
15,909,939 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi all,

Can any one give example of making use of jquery in master page of asp.net and also specify which version of jquery js file to be used as when searching different sites they have varied versions.

my requirment is when the window is unloading i want to insert some data into database.

Thanks in advance
Posted

XML
<script src="Script/jquery-latest.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function() {

       $(window).unload(function() {
         alert('Handler for .unload() called.');});
 });
</script>


This can help you in master page.
 
Share this answer
 
v4
Hi Abdul,
Its working fine but i have one small query exactly what im trying to do is when the user is closing the window i want capture some details and pass it to the DB.
when im using the above function it always gives me the alert, it works fine if im using window.onbeforeunload when not used with jquery.

can you suggest me any other idea.

I have tried with the following code

<pre lang="cs">$(document).ready(function() {
                $(window).unload(function() {
                        var clientx = window.event.clientX;
                        var clienty = window.event.clientY;
                        if ((clientx > 0) || (clienty < 0)) {

                            var c = confirm("do you want to close the window");
                            if (!c) { window.focus(); } else { alert("Thank you for your visit"); }
                            //                            if (event.returnValue = "If you have made any changes to the fields without clicking the Save button, your changes will be lost.") { }
                            //                            else { window.focus(); }
                        }

                    });
                });

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900