Reputation: 71
How can i update a method in controller if a checkbox is checked? see image below https://i.sstatic.net/5RmbK.jpg
>[HttpPost]
>public ActionResult Update(int id)
>{
> //code update status in db
> }
Upvotes: 1
Views: 12968
Reputation: 33839
Try this (Razor syntax):
//for a checkbox
@Html.CheckBox("chkName",false, new {onclick="this.form.submit();"})
//if using strongly typed model property
@Html.CheckBoxFor(model=> model.chkName, new {onclick="this.form.submit();"})
Upvotes: 5