I followed the instructions on this post:
Asp.net mvc3 razor with multiple submit buttons
and here is my model:
public class AdminModel
{
public string Command { get; set; }
}
My Controller
[HttpPost]
public ActionResult Admin(List<AdminModel> model)
{
string s = model.Command;
}
My View
@using (Html.BeginForm("Admin", "Account"))
{
<input type="submit" name="Command" value="Deactivate"/>
<input type="submit" name="Command" value="Delete"/>
}
When I post back, string "s" is always null.
I also tried the second answer (the one with 146 votes) in this forum post : How do you handle multiple submit buttons in ASP.NET MVC Framework? and thats also null. What am I doing wrong?
Best Answer
you need to take the value from their server side by the name of the button,