How to handle two submit buttons in Html.BeginForm in MVC 3 Razor

Below is a form with two submit buttons. Note that both these submit buttons have the same name i.e “submitButton”

@Html.BeginForm("MyAction", "MyController"); %>
<input type="submit" name="submitButton" value="Button1" />
<input type="submit" name="submitButton" value="Button2" />

Now over to the Controller, the Action takes in an input parameter called string stringButton and the rest is pretty self-explanatory.

public ActionResult MyAction(string submitButton) {
switch(submitButton) {
case "Button1":
// do something here
case "Button2":
// do some other thing here
// add some other behaviour here


Hope this helps you !