using (Ajax.BeginForm("SaveTimeShift", new AjaxOptions { HttpMethod = "Get", UpdateTargetId = "recordList", InsertionMode = InsertionMode.Replace }))
Why is it when i used this overloaded constructor of Ajax.BeginForm above i get the
updated data in my model but when i used this overloaded constructor below i dont get the updated value of my Model? I need the constructor below in order for me to set the html class attribute of my form…
using (Ajax.BeginForm("SaveTimeShift", @Model, new AjaxOptions { HttpMethod = "Get", UpdateTargetId = "recordList", InsertionMode = InsertionMode.Replace }, new { @class = "form-inline" }))
{
@Html.TextBoxFor(model => model.StartDate, new { id = "startDate", @readonly = true, width = "100px" })
@Html.HiddenFor(model => model.SelectedName, new { id = "selectedName" });
@Html.HiddenFor(model => model.SelectedUserId, new { id = "selectedUserId" });
<input class="btn btn-primary pull-right" type="submit" value="Save Time Shift" />
}
The second
Ajax.BeginForm()has the following method signature:Your trying to pass
@Modelas a route value, which isn’t how model binding works. The model binder will construct your complex model object via the form values that are posted. Changing yourAjax.BeginForm()method to the following should solve your problem: