|
-
Mar 22nd, 2005, 10:46 AM
#1
Thread Starter
Addicted Member
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,
never argue with an idiot, he will bring you down to his level and will beat you through experience
-
Mar 22nd, 2005, 11:30 AM
#2
PowerPoster
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.
-
Mar 22nd, 2005, 12:11 PM
#3
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.
-
Mar 22nd, 2005, 01:06 PM
#4
PowerPoster
Re: page_unload does something else then i expected
-
Mar 23rd, 2005, 02:32 AM
#5
Re: page_unload does something else then i expected
The solution to all the world's problems!
-
Mar 23rd, 2005, 03:12 AM
#6
Thread Starter
Addicted Member
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...
is there no base class events like "load" or "disposed" or "init" that would trigger when the user leaves the page?
never argue with an idiot, he will bring you down to his level and will beat you through experience
-
Mar 23rd, 2005, 05:13 AM
#7
Thread Starter
Addicted Member
Re: page_unload does something else then i expected
 Originally Posted by demoti
I use a framework
i meant frameset: i redirect with frameredirect(me, "urlstring")
never argue with an idiot, he will bring you down to his level and will beat you through experience
-
Mar 23rd, 2005, 10:46 AM
#8
PowerPoster
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.
-
Mar 23rd, 2005, 11:16 AM
#9
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
-
Mar 24th, 2005, 06:29 AM
#10
Thread Starter
Addicted Member
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...
never argue with an idiot, he will bring you down to his level and will beat you through experience
-
Mar 25th, 2005, 03:07 AM
#11
Thread Starter
Addicted Member
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...
never argue with an idiot, he will bring you down to his level and will beat you through experience
-
Mar 25th, 2005, 03:40 AM
#12
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();
-
Apr 12th, 2005, 10:01 AM
#13
Thread Starter
Addicted Member
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!
never argue with an idiot, he will bring you down to his level and will beat you through experience
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|