I've currently got a View like this:
@using (Html.BeginForm("Compare", "Carousel", FormMethod.Post))
{
@foreach (var product in Model.Products)
{
<tr>
<td>@product.Provider.Name</td>
<td>£@Math.Round(product.MonthlyPremium, 2, MidpointRounding.AwayFromZero)</td>
<td>@Html.ActionLink("More Details", "MoreDetails", new { id = product.ProductId })</td>
<td><button name="compare" value="@product.ProductId">Compare</button</td>
</tr>
}
}
Controller:
[HttpPost]
public ActionResult Compare(ProductsWithDetailModel model) // This is a guess, Model may not persist?
{
// Code here
return View("Index", model);
}
What I actually want is, when a button is clicked, the Controller is going to be called and the product that has been selected (the button clicked) will be added to a list of items.
How do I actually find out which button has been clicked in the Controller? How come I cant find any tutorials out there on the web that have done this before, surely its basic functionality? Or am I approaching it wrong?