I have got several forms on my page. Here is an example of one.
<table width="400px">
@foreach (var menu in Model)
{
using (Html.BeginForm())
{
<tr>
<td>
@menu.Menus
</td>
<td>
@menu.Submenu
</td>
<td>
<input type="submit" name="update" value="Update" />
<input type="submit" name="delete" value="Delete" />
@Html.Hidden(@menu.MenuID.ToString());
</td>
</tr>
}
}
</table>
I want each of my actions to be invoked by the forms submit button. So the an action will be invoked depending on whether there was the update submit button pressed, or delete button pressed or whether a button was pressed with no name attribute…I also want my form to be post for only.
How can I achieve all that?
In the view you wrap each button with its own form. For example for update
For each action you’ll have in the controller
I believe though the update needs more than an id, those fields should be included in the form and in the action’s arguments.