First, make the button type
submit
-
<button type="submit" class="btn btn-blue">Save
Second, give
action
to form-
<form role="form" action="@Url.Action("SaveToDb", "ControllerName")" class="form-horizontal" method="POST">
Third, attribute the method as
HttpPost
and should be
ActionResult
-
[HttpPost]
public ActionResult SaveToDb(AddressViewModel addrs)
{
var addressLine1 = addrs.AddressLine1;
var addressLine2 = addrs.AddressLine2;
var city = addrs.City;
return View("SomeView");
}
Now, put a breakpoint on the very first line of the SaveToDb method and see if control is actually getting here or not. And make sure that the model used in form is same as used in method.
-KR