Many Buttons on a Page, Need to send back Unique Post Data with each
- by CoffeeAddict
I'm listing out a bunch of cars with a button next to them that when clicked will need to perform a GET but also sends over that item's model.Name:
@using (Html.BeginForm("GetCarUrl", "Car", FormMethod.Get, new { model = Model }))
{
if(Model.Cars != null && Model.Cars.Count > 0)
{
foreach (CarContent car in Model.Cars)
{
<p>@car.Name</p>
}
<input type="button" value="Get Car Url" class="submit" />
}
So the page renders a bunch of hyperlinks and buttons:
[hyperlink1] [submit]
[hyperlink2] [submit]
[hyperlink3] [submit]
[hyperlink4] [submit]
[hyperlink5] [submit]
...
When a user clicks on any of the submits, I need to pass back its corresponding @car.CarType for that specific hyperlink
Not sure how to go about this. My action method expects a @car.CarType for that specific car hyperlink to be sent to it