I have two buttons on my MVC form:
<input name="submit" type="submit" id="submit" value="Save" />
<input name="process" type="submit" id="process" value="Process" />
From my Controller action how do I know which one have been pressed?
I have two buttons on my MVC form:
<input name="submit" type="submit" id="submit" value="Save" />
<input name="process" type="submit" id="process" value="Process" />
From my Controller action how do I know which one have been pressed?
Here's a really nice and simple way of doing it with really easy to follow instructions using a custom MultiButtonAttribute:
http://blog.maartenballiauw.be/post/2009/11/26/Supporting-multiple-submit-buttons-on-an-ASPNET-MVC-view.aspx
To summarise, make your submit buttons like this:
Your actions like this:
And create this class:
To make it easier I will say you can change your buttons to the following:
Your controller:
Give the name to both of the buttons and Get the check the value from form.
On controller side :
And in your controller action: