How to clear postbacks from window.history?

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.
 
A

andrew.douglas11

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
 
C

cashdeskmac

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
 

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,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top