Handle multiple button post

razor:

1
2
3
4
5
<code><form action="" method="post">
<strong> <input type="submit" value="Save" name="action:Save" />
 <input type="submit" value="Send" name="action:Send" /></strong>
</form>
</code>
<code><form action="" method="post">
<strong> <input type="submit" value="Save" name="action:Save" />
 <input type="submit" value="Send" name="action:Send" /></strong>
</form>
</code>

and controller:

1
2
3
4
5
6
7
8
<code>    [HttpPost]
    <strong>[MultipleButton(Name = "action", Argument = "Send")]</strong>
    public ActionResult Send(MessageModel mm) { ... }
 
    [HttpPost]
    <strong>[MultipleButton(Name = "action", Argument = "Save")]</strong>
    public ActionResult Save(MessageModel mm) { ... }
</code>
<code>    [HttpPost]
    <strong>[MultipleButton(Name = "action", Argument = "Send")]</strong>
    public ActionResult Send(MessageModel mm) { ... }

    [HttpPost]
    <strong>[MultipleButton(Name = "action", Argument = "Save")]</strong>
    public ActionResult Save(MessageModel mm) { ... }
</code>
Share the joy
  •  
  •  
  •  

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.