How to clear postbacks from window.history?

  • Thread starter Thread starter cashdeskmac
  • Start date Start date
C

cashdeskmac

Hi,

Is it possible to clear the recent history so that a link with the href
"javascript:window.history.back()" doesn't record any postbacks?

For example, if I the user makes a few selections on a page and clicks the
Back link, I want them to go to the previous page rather than going to the
previous state of the page.

Any help is appreciated as always.
 
One way that you could solve your problem is to use the AJAX
Extensions. After you install the AJAX Extensions, if you put content
inside of an UpdatePanel control, and the user clicks something inside
it, a PostBack will still occur, but only the portion of the screen
contained in the UpdatePanel will be refreshed after the PostBack. So
if you click the Back button, it will act as if the PostBack never
happened. Here's some code for you:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="lblTime" runat="server"></asp:Label>
<asp:Button ID="btnRefreshUpdatePanel" runat="server"
Text="Do PostBack" />
</ContentTemplate>
</asp:UpdatePanel>

If you have a page foo.html that links to a page foo.aspx which
contains the above UpdatePanel, the user can click the "Do PostBack"
button as many times as they want, and you can still press the
browser's Back button to get back to foo.html.

Hope this helps
Andy
 
Fantastic. Thank you very much. :-)

One way that you could solve your problem is to use the AJAX
Extensions. After you install the AJAX Extensions, if you put content
inside of an UpdatePanel control, and the user clicks something inside
it, a PostBack will still occur, but only the portion of the screen
contained in the UpdatePanel will be refreshed after the PostBack. So
if you click the Back button, it will act as if the PostBack never
happened. Here's some code for you:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="lblTime" runat="server"></asp:Label>
<asp:Button ID="btnRefreshUpdatePanel" runat="server"
Text="Do PostBack" />
</ContentTemplate>
</asp:UpdatePanel>

If you have a page foo.html that links to a page foo.aspx which
contains the above UpdatePanel, the user can click the "Do PostBack"
button as many times as they want, and you can still press the
browser's Back button to get back to foo.html.

Hope this helps
Andy
 
Back
Top