Saving Data When ASP.Net Page Unloads

  • Thread starter Roy Scarisbrick
  • 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
 
N

Natty Gur

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
 
D

David Waz...

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top