title: Submit multiple buttons on same view
body: <p>I need to have multiple buttons on same view, but for some reason it doesn't work. I did already looked at the same questions but I haven't got a solution.</p>
  
  <p>How do I know which button is performed in the view?</p>
  
  <p>View:</p>
  
  <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage&lt;LIASWeb.Models.Publication&gt;" %&gt;
  
  &lt;asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"&gt;
  
      &lt;h2&gt;NewPublication&lt;/h2&gt;
  
      &lt;% using (Html.BeginForm())
         { %&gt;
      &lt;div&gt;
          &lt;fieldset&gt;
              &lt;p&gt;
                  &lt;label for="Name"&gt;Naam:&lt;/label&gt;
                  &lt;%: Html.TextBoxFor(m =&gt; Model.nmPublication) %&gt;
              &lt;/p&gt;
              &lt;p&gt;
                   &lt;%: Html.TextBox("Search", "type naam")%&gt;
                  &lt;input type="submit" name="btnSearch" value="Zoeken" /&gt;
              &lt;/p&gt;
              &lt;p&gt;
                  &lt;input type="submit" name="btnSave" value="Opslaan" /&gt;
              &lt;/p&gt;
          &lt;/fieldset&gt;
      &lt;/div&gt;
      &lt;% } %&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>public class PublicationController : Controller
  {
      private Repository repository = null;
  
      public PublicationController()
      {
          repository = new Repository();
      }
  
      public ActionResult NewPublication(String button)
      {
          if (button == "btnSave")
              // perform save action
  
              if (button == "btnSearch")
              // perform save action
  
          return View();
      }
  
      public ActionResult Index()
      {
          IEnumerable&lt;Publication&gt; model = repository.Publications;
          return View(model);
  </code></pre>
  
  <p>}</p>
  
  <p>Routings:</p>
  
  <pre><code>public static void RegisterRoutes(RouteCollection routes)
  {
      routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  
      routes.MapRoute(
          name: "Default",
          url: "{controller}/{action}/{id}",
          defaults: new { controller = "Publication", action = "Index", id = UrlParameter.Optional }
          );
  }
  </code></pre>