Saving Data When ASP.Net Page Unloads

  • Thread starter Thread starter Roy Scarisbrick
  • Start date Start date
R

Roy Scarisbrick

I have a programming issue on an ASP.Net web page. I suspect the issue would
apply to any version of ASP though.


I have a questionnaire page where a user will answer a bunch of questions
with radio buttons and text boxes. At the bottom of the page is a button
that he is to click when he's done. The event behind the button will write
the data to the database and redirect him to a Thanks page.


The issue is what happens if the user supplies the data, then just closes
the browser window. As it is, the data doesn't get written. There is a
Page_Unload event that I don't understand completely. First, it fires when
the page has finished loading, which I've read is expected, and second, when
the page is closed there doesn't seem to be much you can actually do there,
as by the time the event fires, the session is closed. That is documented as
well.


My question is: how can I ensure the data gets written? Are there
traditional ways to stop a browser window from being closed, or at least to
call another sub when it is?






Roy Scarisbrick, B.A. (Economics), Certified Engineering Technologist

Calgary, Alberta, Canada, T2P 4H3

www.HeadwaySystems.com
 
Hi,

If you use just IE you can use the OnBeforeUnload with XMLHTTP or
webservice.htc to accomplish it.

Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
 
I don't think you want the data if the user closes the window.

Most people know how to use a web page. capturing the data when the window
closes, or without the users direct action makes the value of the data
suspect.
 
Back
Top