Posts Tagged ‘MVC4 Razor : How to get the value from view to controller’
MVC4 Razor : How to get the value from view to controller ?
Here i explain how to get the value from html razor control (view) to controller
Code in View:
<input type=”submit” value=”Send” />
Code in Controller
public ActionResult Index1(FormCollection collection)
string customerName = collection[“txtCustomerName”].ToString();
After press send button the value will be catch in controller (as like below)
As above , we can get value of other control from the view to controller
1. [AcceptVerbs(HttpVerbs.Post)] , will do action when we use Html.BeginForm()
2. FormCollection : It provides to access the values that were just posted to your page.