ASP.NET MVC 4: Changing the Value of a Hidden field in Javascript
asp.net-mvc, asp.net-mvc-4, c#, jquery, razor
Solution
Make sure you include a leading # in the Jquery selector, as the MVC HtmlHelper does not output it.
Problem
I have a hidden boolean field : ``` @Html.HiddenFor(x => x.IsTurkey) ``` In jQuery script I try to change it: ``` $("@Html.IdFor(x => x.IsTurkey)").val("False"); ``` But on the post back IsTurkey is not changed: ``` HttpPost] [ValidateAntiForgeryToken] public ActionResult Search(TurkeyModel model) { ...} ``` Using jQuery as above, how do I change the value of a hidden boolean field in MVC 4 ?