I have code like below in ASP.Net MVC4. and I am using Razor engine.
@{ string sDefaultEnvironId = string.Empty; } <script language="javascript" type="text/javascript" > function changeHd() { $("#hdSelEnvironmentId").val("1"); } </script> <input type="button" value="ChangeHD" onclick="changeHd();" /> @Html.Hidden("hdSelEnvironmentId", sDefaultEnvironId) The value of hidden field hdSelEnvironmentId is empty when accessing this view at first time. then it was changed to 1 after I clicked button ChangeHD. But after I pressed F5, the value of hidden field hdSelEnvironmentId is still 1, I expected it with initial empty value instead of 1. Can anyone help me to figure it out ?I just can not understand it. I am using Firefox and Firebug, thanks.