I can't believe I've never noticed this before, but searching has brought up nothing on this particular oddity.
In the code below if you cycled through the dropdown options (select 2, 3, 4, 5 in order) you will see the correct values displayed in the label.
Now if you click the browser's back button once you will see "Five" in the dropdown, and "you selected item number Four" in the label.
Click the browser's back button again, you will see "Four" in the dropdown and "you selected item number Three"
Clicking again brings forth the same mismatch, you will see "Three" in the dropdown and "you selected item number Two" in the label.
What gives? I tried setting up a jquery trigger to perform the dropdown's postback hoping this would give the browser time to "register" the fact that the dropdown value changed - but that yielded the same results as explained above
The "code" is here:
ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="Test_DropdownHistory._default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="ddlHistoryTest" runat="server" OnSelectedIndexChanged="ddlHistoryTest_SelectedIndexChanged" AutoPostBack="true">
<asp:ListItem Text="One" Value="One" />
<asp:ListItem Text="Two" Value="Two" />
<asp:ListItem Text="Three" Value="Three" />
<asp:ListItem Text="Four" Value="Four" />
<asp:ListItem Text="Five" Value="Five" />
</asp:DropDownList>
</div>
<div>
<asp:Label ID="lblHistoryTest" runat="server" Text="This is the default text" />
</div>
</form>
</body>
</html>
CS
public partial class _default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ddlHistoryTest_SelectedIndexChanged(object sender, EventArgs e)
{
lblHistoryTest.Text = "you selected item number " + ddlHistoryTest.SelectedValue;
}
}