简体   繁体   English

重新浏览整个页面后如何清除下拉列表框。 使用asp.net mvc

[英]How to clear the dropdown list box after refresing whole page. using asp.net mvc

I have a dropdown list boxes in the page. 我在页面中有一个下拉列表框。

When I Load the page. 当我加载页面时。 the dorpdown list boxes values not showing Please Select.. its allways showing the previously selcted value. dorpdown列表框中的值未显示“请选择”。其始终显示先前选择的值。

why its not defaulting it to Please select is that I am doing something wrong in this aspx page? 为什么不将其默认设置为“请选择”,因为我在此aspx页中做错了什么?

thanks 谢谢

That's a function in the browser. 那是浏览器中的功能。 It remembers what you entered in the form previously, and fills the form automatically. 它会记住您之前在表格中输入的内容,并自动填写表格。

Press Ctrl + F5 to reload the page without remembering form data. Ctrl + F5重新加载页面,而无需记住表单​​数据。

That is the default behavior of most of the browser. 这是大多数浏览器的默认行为。 You need to do Ctrl + F5 to reload it fresh. 您需要执行Ctrl + F5来重新加载它。

Most likely because it is finding existing values for those drop down lists in the ModelState and applying those. 最有可能的原因是,它正在为ModelState中的那些下拉列表找到现有值并应用这些值。

Try adding this code to your Index method: 尝试将以下代码添加到您的Index方法中:

ModelState.Clear();

This is assuming you mean after you click the Save button? 这是假设您的意思是单击“保存”按钮后?

Load the dropdown on 加载下拉列表

$(document).ready(function () { $(document).ready(function(){

}); });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM