1

I am trying to send a property of a Model to the Action in Controller by adding a hidden input to the View like following:

In the Model I have this property:

public bool Status { get; set; }

In the View inside the form I added this:

<input type="hidden" id="Status" name="Status" value="@Model.Status" />

I have debugged the code in the view and @Model.Status is true.

Here is the action:

[HttpPost]
public ActionResult EditMember(Member member)
{
  ....
}

It should bind the value of the hidden input to the Status property of the Model. However when it comes to the action the status is false. And the ModelState is not valid and says 'The value of value is not valid for Status'. I checked that the value of property is 'value' when it tries to bind the property so it will be an error and the Status Property be false.

Chandan Rauniyar
  • 814
  • 1
  • 14
  • 24
user217648
  • 3,338
  • 9
  • 37
  • 61

0 Answers0