How can I invoke controller action and send which values are selected in drop down lists in time when button was clicked? Here is example how my .cshtml looks like. This is just example, generally I need to collect much data from current view in time when button was clicked.
<body>
<div>
@Html.DropDownList("Name")
<br />
@Html.DropDownList("Age")
<br />
@Html.DropDownList("Gender")
<br />
@using (Html.BeginForm("FindPerson", "MyController", FormMethod.Post))
{
<input type="submit" value="Find" />
}
</div>
</body>
In order for the data to be submitted to the controller, the inputs must appear within the <form>
tag.
For example:
<body>
<div>
@using (Html.BeginForm("FindPerson", "MyController", FormMethod.Post))
{
@Html.DropDownList("Name")
<br />
@Html.DropDownList("Age")
<br />
@Html.DropDownList("Gender")
<br />
<input type="submit" value="Find" />
}
</div>
</body>