I\'m wondering how you might go about implementing multiple form actions when submitting a form in asp.net mvc 3 RC.
If I\'m editing a user, for example I would like to
You can have multiple submit buttons in a form with the same name
attribute but different value
attributes. Which ever button is clicked, the associated value
will be posted to the server.
You can use a simple link for Cancel
but I'll include it as a button anyway.
And in your action, test for the values.
public ActionResult Edit(string actionType)
{
if(actionType == "Save")
{
// Save action
}
else if (actionType == "Save and Close")
{
// Save and quit action
}
else
{
// Cancel action
}
}
If you don't like having the long text in the value
attribute, you can use standard HTML tag which lets you define a separate value and separate text.