page_unload does something else then i expected
Hello,
I have some asp.net page with save-buttons. When the save-button is pressed the inputted data in the form is saved to sql-db.
I think my application would look a lot nicer if the form would be saved automatically when i go to another page.
I thought copying the code to the "unload-event" of the page would do that for me but apparently it does not. I tried al the page-events that i know of and still don't know what event is raised when you close a page...
any help? this can't be too tough i hope...
thanks in advance,
Re: page_unload does something else then i expected
How does the person go to the next page?
Using Page.IspostBack might help in the page_load event.
Re: page_unload does something else then i expected
The other way to go to a page would be through a link. Set your save code in the link's click event.
Re: page_unload does something else then i expected
Re: page_unload does something else then i expected
The solution to all the world's problems! :afrog:
Re: page_unload does something else then i expected
thanks for your reply.
I use a framework and the links to the other pages are all in the left frame, the frame that has to be saved is in the right. i can't call the save-function from the left without reviewing a lot of code... :rolleyes:
is there no base class events like "load" or "disposed" or "init" that would trigger when the user leaves the page?
Re: page_unload does something else then i expected
Quote:
Originally Posted by demoti
I use a framework
i meant frameset: i redirect with frameredirect(me, "urlstring")
Re: page_unload does something else then i expected
I dont think so that you would be able to find any such event. In asp the page_unload is called when the page is sent to the browser unlike windows forms.
Re: page_unload does something else then i expected
You may be able to do this with java script in the client side.
When you gert a PM on VBF do you notice how when you try to navigate away from the PM page, or close IE down, you get a message box asking if you want to send a reciept. All you would do is save your code here...you could even use remoting.
Check out the source code for a PM page.
When you read this let me know, and I'll send u a PM, so you can check it out.
Woka
Re: page_unload does something else then i expected
thanks for your replys,
although i was hoping there was an event, i'll try to find out what happens when wokawidget sends me an email...
i'll be posting my findings here, but i kinda have a virus-outbreak inhere so it'll be more probably tomorrow...
Re: page_unload does something else then i expected
<code>function checkpm(formname)
{
if (formname.dopreview != true)
{
if (confirm("Request a read receipt for this message?"))
{
formname.receipt.value = 1;
}
}
return validatePost(formname, formname.title.value, 0, 2000);
}
</script>
<form action="private.php" method="post" onsubmit="return checkpm(this)" name="vbform" onreset="vB_RESET(this);">
</code>
this might be usable but i can't submit the form from an other frame...or can i?
also i won't be able to read the textboxvalues (etc) from the vbscript...
Re: page_unload does something else then i expected
You can submit a form from another frame using js like so:
Code:
top.frames.targetframename.document.forms.formname.submit();
Re: page_unload does something else then i expected
better late than never:
when you try to close the page or navigate to the URL the application will display a messagebox that you will lose data if you go on without saving.
the key here seemed to be the onbeforeunload event handler
here is the link: Using ASP.NET to Prompt a User to Save When Leaving a Page.
all glory to XIII(forums.asp.net) who provided me with this info!