ModelBinder is not working after adding explicitly arguments to Html.BeginForm()

75 Views Asked by At

In controller I obtain StudentID from POST method from a View. Basically the line is:

public ActionResult Edit(int? StudentID) {}

In the View, I have a hidden field to provide the StudentID. What would be the reason that in View() when I changed the line:

using(Html.BeginForm()) { //... }

to

using (Html.BeginForm("Edit", "Students", FormMethod.Post, new { @class = "form-horizontal" }))

the ModelBinder stops binding StudentID. When I submit the form I receive null instead of correct Student's ID.

0

There are 0 best solutions below