I have cshtml page having code like this
model Kouponer.Models.person_T
@using (Html.BeginForm("BuynowForm", "Home"))
{
<label>@Model.name</label>
<label>address</label>
@Html.TextBox("address")<div>
<input type="submit" value="Submit" class="btn btn-primary" />
}
And my current actionresult method is
[HttpPost]
public ActionResult BuynowForm(FormCollection col)
{ string address = col["address"];
return View();
}
Here I will get only the formcollection values. How to pass the model along with the formcollection?
In the
Controllerclass ofSystem.Web.Mvcnamespace there is anHttpRequestBaseproperty calledRequestwith all the data of the current http request. Among its properties, there is theNameValueCollectionproperty calledFormyou are looking for.The usage would be something like this: