In an ASP.NET MVC application, I create logic for the administrator to accept or decline new members. I show a list of participants and two Accept and Reject buttons, for example:
<% foreach (var mm in (ViewData["pendingmembers"] as List<MyMember>)) %>
<% { %>
<tr><td>Username:<%=mm.UserName %></td><td>
<tr><td>Firstname:<%=mm.FirstName %></td><td>
...etc...
<tr>
<td>
<% using (Html.BeginForm("AcceptPendingUser", "Admin"))
{ %>
<input type="submit" value="Accept" />
<% } %>
</td>
<td>
<% using (Html.BeginForm("RejectPendingUser", "Admin"))
{ %>
<input type="submit" value="Reject" />
<% } %>
</td>
</tr>
<% } %>
So, the list of pending item data is in the list of MyMember objects. Each MyMember object will be printed by a member, and two buttons are configured for the administrator to accept or reject the pending item.
Then in the controller, I separate the processing of these two input / form fields, for example:
public ActionResult AcceptPendingUser()
{
return RedirectToAction("Index");
}
public ActionResult RejectPendingUser()
{
return RedirectToAction("Index");
}
I would like to immediately get the object next to the button pressed by the user. How can I send a MyMember object from a view to a controller? Or how can I send a numerical index with a click of a button? Maybe with a hidden field?