You don't really need to have multiple forms and achieve the same using a single form. As always, there are multiple ways to achieve this. I am giving one of them. Check out the following example...
Add a class called UserData that would contain a property with validation rules.
public class UserData
{
[Required(ErrorMessage="Name is required")]
public string Name { get; set; }
}
The following are the action methods (for initial display and post action):
public ActionResult MultipleButtons()
{
return View();
}
[HttpPost]
public ActionResult MultipleButtons(UserData userData, string submit)
{
if (submit == "Action 1")
{
}
else
{
}
return View(userData);
}
Finally, the MultipleButtons view looks like this:
@model TestMvcApp3.Controllers.UserData
@using (Html.BeginForm())
{
@Html.TextBoxFor(m => m.Name) @* Displays a text box and binds it to the "Name" property *@
@Html.ValidationMessageFor(m => m.Name) @* Display validation messages if any *@
<input type="submit" value="Action 1" name="submit" /><input type="submit" value="Action 2" name="submit" />
}
Hope this helps!