DropDownList SelectedIndex problem in FireFox after page refresh
Posted
by jartur
on Stack Overflow
See other posts from Stack Overflow
or by jartur
Published on 2010-03-30T14:09:59Z
Indexed on
2010/03/30
14:13 UTC
Read the original article
Hit count: 544
I've got DropDownList in UpdatePanel as shown below:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
<div>
Index: <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</div>
</ContentTemplate>
</asp:UpdatePanel>
In my codebehind i've got this simple code:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
FillDropDownList();
}
}
private void FillDropDownList()
{
for (int i = 0; i < 10; i++)
{
DropDownList1.Items.Add(new ListItem(i.ToString(), i.ToString()));
}
DropDownList1.SelectedIndex = 0;
Label1.Text = DropDownList1.SelectedIndex.ToString();
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Label1.Text = DropDownList1.SelectedIndex.ToString();
}
Here is the problem: I select in the list some item grater than 0 e.g. 5, the label shows value 5. But when I refresh the page, by hitting the refresh button in firefox, the label shows value 0 (as it's supposed to) but the dropdownlist shows 5. I checked the page html source and the dropdown has selected value 0, but shows 5. However, When I refresh the page by putting cursor in address bar and press enter everythig works fine (drowdownlist shows 0). The problem occurs only in FireFox (I've got version 3.5.7).
Any ideas what can cause this problem?
© Stack Overflow or respective owner