How to handle going BACK on a website (ASP.NET VS2009 C#)
I have a problem with my web site when dealing with the BACK button...
Imagine the following, I have a DropDownList that allows the user to select an option which, when selected (_SelectedIndexChanged event) sends me to another web page... The problem comes if the user presses BACK afterwards he is returned to the previous page with the DropDownList that still has the option selected.
Therefore, if the user wants to proceed to that option again he has to change to the empty listing in the DropDownList and then select the option to fire off the _SelectedIndexchanged event.
What I want is that, if the user presses BACK it resets the DropDownList.selectedindex=0 (empty) which forces the user to reselect an option - however no matter what I try when the user presses BACK it always returns to how it was even when I reset the selected index of the DropDownList before leaving the selection page.
Is there some special way to handle the BACK button when creating a website? I want to be able to reset the SelectedIndex of my DropDownList in the case where the user presses BACK ...
Any help would be much appreciated - I can't seem to figure out how to get around this rather annoying bug in my site.
I think you'll find there isn't anyway of doing this. When a user clicks back you are simply moving back up the history stack, the page is just reshown as opposed to reloaded, in other words no page processing occurs, so none of your code actually runs so you can't control the display. The only real alternative is to provide your own back button that actually reloads the previous page but of course the user can still click the browser back button unless you hide it, which I would not recommend.