我有一个asp.net DROPDOWNLIST与自动回启用。它不填充动态,它的价值是固定的HTML code:
I have an asp.net Dropdownlist with autopostback enabled. It is not populated dynamically, its values are fixed in the HTML code :
<asp:dropdownlist id="ddlReportView" runat="server" autopostback="True" onselectedindexchanged="ddlReportView_SelectedIndexChanged" enableviewstate="true">
<asp:listitem text="Snapshot" value="SNAPSHOT"></asp:listitem>
<asp:listitem text="Detailled" value="DETAILLED"></asp:listitem>
<asp:listitem text="Review" value="REVIEW"></asp:listitem>
<asp:listitem text="Review Summary" value="REVIEW_SUMMARY"></asp:listitem>
</asp:dropdownlist>
如果我选择一个项目,重新加载,显示了不同的格式列表页。我的问题是,当我点击后退按钮浏览器,DropDownList的值仍然是选择的最后一个值。
If I select an item, it reloads the page to display a list with a different format. My problem is that when I click the back browser button, the dropdownlist's value is still the last value selected.
示例:
起初,该列表是在Snaphshot模式:
At first the list is in Snaphshot mode:
用户,然后点击评测总结方式:
User then clicks on Review Summary mode:
该页面现在显示的评论摘要网格,一切正常:
The page now displays the review summary grid, all is OK:
用户presses返回按钮,网格显示在快照模式(这是确定),但 下拉仍显示评论摘要!
User presses the back button, grid is displayed in snapshot mode (which is OK), BUT the dropdown still shows "Review Summary"!
我尝试设置使用javascript选择的价值,但它不工作。有没有人有这个问题,或者知道如何解决这个问题?
I tried setting the value of the select using javascript, but it does not work. Has anybody had that problem, or knows how to fix that?
感谢。
我设法利用这一个JavaScript的工作jQuery的...
I managed to get the javascript working on this one using jQuery...
$(document).ready(function() {
//Reset drop down list
$("#<%= dropDownList1.ClientID %> > option:first").attr("selected", "selected");
});
如果初始值应该是快照选项...
or if the initial value should be the 'SNAPSHOT' option...
$(document).ready(function() {
$("#<%= dropDownList1.ClientID %>").val("SNAPSHOT");
});