What I would do in this situation is to make these elements available to my ViewModel.
public class MyViewModel { public bool text1 { set;get} public bool text2 { set;get;} public bool SomeMeaningFullName { set;get;}
and in my Get Action method I will return this ViewModel to my view
public ActionResult Edit() { MyViewModel objVM=new MyViewModel(); return View(objVM); }
and in my view
@model MyViewModel @using (Html.BeginForm("Edit","yourcontroller")) { @Html.LabelFor(Model.text1) @Html.CheckBoxFor(Model.text1) @Html.LabelFor(Model.text2) @Html.CheckBoxFor(Model.text2) <input type="submit" value="Save" /> }
Now this property value will be available in your post action method
[HttpPost] public ActionResult Edit(MyViewModel objVM) {
Shyju source share