Post Back on Web User Control

G

Guest

When I leave a page that has a user control and press the back button on my browser I notice that the Page_Load event of the user control doesn't fire unless i do a refresh on the page. Is there a way to fire this event when I hit the back button on the browser? Is this by design?
 
G

Guest

Yes, it's by design in that the Back button is handled stricly within the browser and does not invoke a round-trip to the server. So, there's nothing to cause a server-side page load event to be reised

What can you do? Write a client-side onload event for the window object. In javascript, it would start out like this
<SCRIPT for="window" event="onload">. In that script, you can submit the form. (Something like "document.Form1.submit()" ). That will cause a postback to occur

The only question is: How to make sure that the window onload event is not raised when the page is first loaded? You'll need to check the content of some element on your page that you know will be different, depending on whether the page was freshly loaded or not. I've been known to use a hidden text box for such things but others might have for elegant solutions to offer

HTH
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top