I’ve got an asp.net page that uses dynamically populated DropDownLists and OnSelectedIndexChanged events. A few days ago I found a defect where hitting the back button would load the previous page from the browser’s cache, so the DropDownList would already have a selected index (hence the OnSelectedIndexChanged event would not fire properly as it didn’t have the default selected index). I understood the issue and googled around. It’s a well known issue that doesn’t have an easy solution because of how the browser interacts with the page. After a bit of thought, I went with a trivial javascript solution to reset the ddls:
var gvTable = document.getElementById("foo");
if (gvTable != null)
{
var actionDDls = gvTable.getElementsByTagName("select");
for (var i in actionDDls) {
actionDDls[i].value = 0;
}
}
This worked well and I was happy. Until I tested it in IE. In IE, it appears to run the script, THEN load the cached values of the DDL. That is, I observe the DDL snapping back to the 0 index, and then suddenly dropping down to the previously selected value.
I’m sort of at a loss here, I typically debug in firebug, but this works perfectly in firefox and chrome. Any suggestions? Thoughts?
Thank you.
Did you happen to look at history points feature in .NET 3.5? http://www.pin5i.com/showtopic-16198.html. This may help the current issue through a custom state management feature.
HTH.