Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

__dopostback not working

Status
Not open for further replies.

Premalm

Programmer
Mar 20, 2002
164
US
Hi Guys,

In my page whenever the user leaves the page I want to save all the data. So onbeforeunload event I call __dopostback('butUpdate',''). I have written a javascript function
function __dopostback(eventTarget,eventArgument) {
var theform = document.Form1;
theform.__EVENTTARGET.value = eventTarget;
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}

This some how is not working. I want to autosave when the user clicks on a different page.

Any Ideas ?

Thanks
Premal
 
In my page whenever the user leaves the page I want to save all the data
Do you realise that you will never be 100% successful in this?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Yes. I do. We are going to tell the users.
 
OK, have you stepped through the code to see if the function is being called successfully or whether it just isn't firing?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Now I have fixed this problem but I have a new problem.

What happening is, its saving if they click the back button or close the browser or click on a different link. The new problem is after running the autosave code the focus remains on the same page.

i.e So the back button is not working now or if they click on a different link it updates automatically but doesn't go to that page. It stays on the page which is calling the dopostback function.

Any Ideas ?

Thanks
Premal
 
As a detail, I'd look into the GetPostBackEventReference()rather than calling __DoPostBack() directly, but by Posting back to the server, it seems you're interrupting the functionality that would have been executed afterwards.

You may be able to get around it with a server-side redirect or other processing in the case of your own controls, but for the browser's back button etc., you may have to do something especially crafty like post via AJAX (instead of calling "submit") then letting the browser do what it was going to do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top