473,387 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Saving Data When ASP.Net Page Unloads

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
Nov 17 '05 #1
2 2129
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
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #2
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.

"Roy Scarisbrick" <ro*@headwaysystems.com> wrote in message
news:PS***********************@news3.calgary.shaw. ca...
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

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: KS | last post by:
Is it possible to write a javascript that makes a popup window when someone click on buttons/href on my page and close itself when the new page is about to get loaded? I want to prevent the user...
17
by: Jack | last post by:
Hi, This is a strange problem I am encountering. I have a asp page with a confirmation.asp page that saves data to a table. There are few text fields that are captured by the confirmation page as...
2
by: Børge Hansen | last post by:
Hi. I am trying to create functionality for saving the contents (state) of a page. The idea is that when navigating away from a webpage and later returning the state of the textboxes, etc should...
3
by: RCS | last post by:
I have an app that I have different "sections" that I want to switch back and forth from, all while having the server maintain viewstate for each page. In other words, when I am on Page1.aspx and...
0
by: DKode | last post by:
Hello, I am trying to call a UserControl after postback to save data filled out on that usercontrol to sql server. The problem I am having is this, I have 2 LinkButtons that I have setup as...
4
by: Pedro Leite | last post by:
Good Afternoon. the code below is properly retreiving binary data from a database and saving it. but instead of saving at client machine is saving at the server machine. what is wrong with my...
6
by: Jeff | last post by:
Hey (and thank you for reading my post) In visual web developer 2005 express edition I've created a simple website project.. At this website I want users who register to be able to upload a...
1
by: killygolaman | last post by:
Hi Guys, Have been looking at this for a while and not sure if there is a solution but hopefully someone can point me in the right direction: The problem is essential I want to undo an update...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.