Capturing Browser Events

Discussion in 'ASP.NET / ASP.NET Core' started by Scott, Apr 15, 2004.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. When a user leaves a particular page, I need to be sure that a post back is generated in order to capture any changes the user made and save them to a database. This is easy enough to accomplish if the user uses the site's menu to navigate to a new page.

    The problem is in grabbing the changes if the user navigates to another page via the browser forward or back functions or by typing a new address in the address bar. Any ideas on how to trap these browser events programatically and save the changes before the user navigates away?
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    i think the only way to do that is to use Javascript that track the event.


    quote:Originally posted by Scott

    When a user leaves a particular page, I need to be sure that a post back is generated in order to capture any changes the user made and save them to a database. This is easy enough to accomplish if the user uses the site's menu to navigate to a new page.

    The problem is in grabbing the changes if the user navigates to another page via the browser forward or back functions or by typing a new address in the address bar. Any ideas on how to trap these browser events programatically and save the changes before the user navigates away?
    </blockquote id="quote"></font id="quote">
     
  3. Have you tried to wireup the page_unload event on the body.

    quote:Originally posted by Scott

    When a user leaves a particular page, I need to be sure that a post back is generated in order to capture any changes the user made and save them to a database. This is easy enough to accomplish if the user uses the site's menu to navigate to a new page.

    The problem is in grabbing the changes if the user navigates to another page via the browser forward or back functions or by typing a new address in the address bar. Any ideas on how to trap these browser events programatically and save the changes before the user navigates away?
    </blockquote id="quote"></font id="quote">
     
  4. hridpath-

    Thanks for the suggestion. However, page_unload is a server-side, not a client-side event. That is, it fires just after the server renders the html for the page, but before the page is sent to the client. Unload does not fire when the page is unloaded by the client browser.

    Bruce's post suggested javascript and it maybe that either window.onBlur or window.unload can provide the functionality I'm looking for.

     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page