开发者

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

开发者 https://www.devze.com 2023-03-25 15:16 出处:网络
I have a dropdown list boxes in the page. When I Load the page. the dorpdown list boxes values not showing P开发者_C百科lease Select.. its allways showing the previously selcted value.

I have a dropdown list boxes in the page.

When I Load the page. the dorpdown list boxes values not showing P开发者_C百科lease Select.. its allways showing the previously selcted value.

why its not defaulting it to Please select is that I am doing something wrong in this aspx page?

thanks


Most likely because it is finding existing values for those drop down lists in the ModelState and applying those.

Try adding this code to your Index method:

ModelState.Clear();

This is assuming you mean after you click the Save button?


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.


That is the default behavior of most of the browser. You need to do Ctrl + F5 to reload it fresh.


Load the dropdown on

$(document).ready(function () {

});

0

精彩评论

暂无评论...
验证码 换一张
取 消