DropDownList SelectedIndex在页面刷新后在FireFox中不工作

DropDownList SelectedIndex在页面刷新后在FireFox中不工作,firefox,drop-down-menu,updatepanel,selectedindex,Firefox,Drop Down Menu,Updatepanel,Selectedindex,我在UpdatePanel中有DropDownList,如下所示: <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:DropDownList ID="DropDownList1" runat="server"> </asp:DropDownList> <di

我在UpdatePanel中有DropDownList,如下所示:

<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>

索引:
在我的代码隐藏中,我得到了以下简单代码:

 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();
    }
受保护的无效页面加载(对象发送方,事件参数e)
{
如果(!IsPostBack)
{
FillDropDownList();
}
}
私有void FillDropDownList()
{
对于(int i=0;i<10;i++)
{
DropDownList1.Items.Add(新列表项(i.ToString(),i.ToString());
}
DropDownList1.SelectedIndex=0;
Label1.Text=DropDownList1.SelectedIndex.ToString();
}
受保护的void DropDownList1\u SelectedIndexChanged(对象发送方,事件参数e)
{
Label1.Text=DropDownList1.SelectedIndex.ToString();
}
问题是:我在列表中选择了一些大于0的项(例如5),标签显示值5。但是当我刷新页面时,在firefox中点击刷新按钮,标签显示值0(正如它应该显示的那样),但dropdownlist显示值5。我检查了页面html源代码,下拉列表选择了值0,但显示为5。但是,当我将光标放在地址栏并按enter键刷新页面时,everythig工作正常(drowdownlist显示0)。这个问题只出现在FireFox中(我有3.5.7版)


你知道是什么导致了这个问题吗?

Firefox会记住会话中每个select的selectedIndex。这对用户很好,但对开发人员来说却很麻烦。。。我也有同样的问题。如果我找到一个解决方案,我会发布它

看看这个:

它起作用了

在PHP中:

<?
    header("cache-control: no-store");
    header("Pragma: no-cache");
?>


对于任何遇到这个“前向缓存”问题的人,我都很清楚这个问题。

你可以在表单中添加一个名为“自动完成”的属性,并将其设置为“关闭”,以防止Firefox中出现这种行为。我发现这是解决这个问题最简单的方法

例如

<form id="myForm" action="/submithandler/" method="get" autocomplete="off">
...
</form>
$("#myForm").attr("autocomplete", "off");