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?
you need to take the value from their server side by the name of the button,
public ActionResult Admin(List<AdminModel> model,string Command)
{
string s = Command;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With