Saving data while closing a window

M

M B HONG 20

I am working on an ASP.NET web application (C#), and need a web form to
either save data on a click of the "X" (Top right corner of the
browser) or just disable the "X" altogether. I have a "Save" button
which is tied to a C# event which saves all of my data via from
sessions, or from the form directly etc., but i need it to save the
data in the event that the user decides to close it with the "X". I am
aware of the browser's native onClose property, but I am not sure if it
can call a C# command from there, and also if it can call a C# command,
does that C# command have access to the form's fields? Any help would
be greatly appreciated.
 
P

Peter Rilling

It is unlikely that you will be able to invoke a postback when the window
closes. Now you might be able to hook the close event in JavaScript and
alert the user. Maybe even give them a chance to cancel the close so they
can save their work. Ultimately this would be user error if they close the
window with data that has not been saved.
 

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,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top