1

I am working on an ASP.NET application which has the following Back button on all the pages in application.

<input type="button" id="btnBack" onclick="history.back();" value = "<- Back" />

There is a particular Test.aspx page in which this is not working most of the time. Test.aspx page only has a dropdownlist with autopostback set to true.

When I change the value in the dropdownlist to some value, say from the default value value1 to value2, and if I then click on the btnBack, it doesn't work most of the times. When it doesn't work, I see that the browser's back button is disabled.

The interesting this is that this occurs only on Test.aspx page.

I read this question: IE8 Back Button Stops Working on ASP .NET Page. but it did not help much unfortunately.

Edit: I also set Page.SmartNavigation = true; in the code-behind to prevent the postback from being added to browser history, but it did not help as well.

Community
  • 1
  • 1
Animesh
  • 4,926
  • 14
  • 68
  • 110

1 Answers1

1
When it doesn't work, I see that the browser's back button is disabled.

This is the main clue that this call is not work, because this function actually call the same function as this button. If there is no previous page for any reason, then can not go back.

Aristos
  • 66,005
  • 16
  • 114
  • 150
  • Yes, that is true, I realized that. Is it possible to detect why the history.length is becoming zero? – Animesh Jul 20 '12 at 14:31
  • @Animesh because you open a new tab, or a new window, or you make ajax calls – Aristos Jul 20 '12 at 14:50
  • I now made sure I am not doing any of those and still facing the problem. – Animesh Jul 21 '12 at 05:20
  • @Animesh This history.back, have all that problems, is not a good navigation way. – Aristos Jul 21 '12 at 05:52
  • Ok aristos, thank you. Could you please suggest any alternate way of navigation? If not, was thinking to be happy with the site map navigation. – Animesh Jul 21 '12 at 06:14
  • @Animesh I do not know what you made there, but everything else is good. Menou, Site Map, History of what user see, actual links that move to the correct page, similar pages... – Aristos Jul 21 '12 at 06:20