I've 2 asp.net pages..page A and page B. On clicking a link on page A, user gets redirected to page B.When on page B, if user clicks browser's back button, I need to forcefully invoke page refresh of page A. How do I achieve this functionality? Note:Code needs to be compatible across different browsers...ie IE, firefox, opera, etc
There is some button property like Autopostback, you can try it and see if ti helps!
I think there is no way for Javascript to tell whether it is the first visit or coming from the back button. So I put the parts of the page that need to be updated in an UpdatePanel, and then do the JavaScript to always refresh these on every page load. Not very elegant but it fixes my problem.
function addLoad(fn) {
if (window.addEventListener) {
window.addEventListener("load", fn, false);
return true;
} else if (window.attachEvent) {
var r = window.attachEvent("onload", fn);
return r;
} else {
return false;
}
}
function refreshBack()
{
__doPostBack("<%= updatePanel1.ClientID %>", "");
__doPostBack("<%= updatePanel2.ClientID %>", "");
}
addLoad(refreshBack);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With