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 ?
确保在Jquery选择器中包含前导#,因为MVC HtmlHelper不会输出它。
我不确定您IdFor
的确切代码,但是您可以执行以下操作:
$("#IsTurkey").val(false);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.