title: MVC 5 multiple submit on one view
body: <p>I know that this has been asked multiple times. But so far I have not found a working solution.</p>
  
  <p>I have the following code in a view:</p>
  
  <pre><code>@using (Html.BeginForm("RoleEdit", "AccountRoles", FormMethod.Post, new { id = "updaterole" }))
  {
      &lt;button name="mySubmit" formaction="@Url.Action("SetDefaultRole", "AccountRoles")" value="MakeDefault" class="button small"&gt;Make Default&lt;/button&gt;
  
      ...
  
  
      other code
  
      ...
  
      &lt;button type="submit" class="button small" value="save" name="save" id="save"&gt;@Resources.DashBoardTags.UpdateRoleTag&lt;/button&gt;
  }
  </code></pre>
  
  <p>And in the controller:</p>
  
  <pre><code>   [HttpPost]
      public ActionResult SetDefaultRole()
      {
  
          return View();
      }
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>    [HttpPost]
      public ActionResult RoleEdit(List&lt;UserRole&gt; userRole, string mySubmit)
      {
  
          if (mySubmit == "Save Draft")
          {
              //save draft code here
          }
          else if (mySubmit == "Publish")
          {
              //publish code here
          }
       }
  </code></pre>
  
  <p>When the code executes:</p>
  
  <ol>
  <li><p>When clicking on the first submit button it ignores the SetDefaultRole function and executes the RoleEdit function.</p></li>
  <li><p>The RoleEdit function value mySubmit is null.</p></li>
  </ol>
  
  <p>Please show my the error of my ways !!!!</p>
  
  <p>I have looked at the proposed solution: <a href="https://stackoverflow.com/questions/442704/how-do-you-handle-multiple-submit-buttons-in-asp-net-mvc-framework">Proposed Solution</a></p>
  
  <p>From this I have created an attribute extension called MultipleButton and changed my code so that the the code now looks like this:</p>
  
  <p><strong>View:</strong></p>
  
  <pre><code>@using (Html.BeginForm("RoleEdit", "AccountRoles", FormMethod.Post, new { id = "updaterole" }))
  {
     &lt;button value="SetDefaultRole" name="action:SetDefaultRole" class="button small" formmethod="post"&gt;Make Default&lt;/button&gt;
  
      ...
  
  
      other code
  
      ...
  
      &lt;button value="RoleEdit" name="mySubmit:RoleEdit" class="button small" formmethod="post"&gt;@Resources.DashBoardTags.UpdateRoleTag&lt;/button&gt;
  }
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>    [HttpPost]
      [MultipleButton(Name= "action", Argument = "SetDefaultRole")]
      public ActionResult SetDefaultRole()
      {
  
          return View();
      }
  
      [HttpPost]
      [MultipleButton(Name = "action", Argument = "RoleEdit")]
      public ActionResult RoleEdit(List&lt;UserRole&gt; userRole)
      {
          return View();
      }
  </code></pre>
  
  <p>Within the new extension, MultipleButtonAttribute shown in the Proposed Solution link above, is executed, the following line of code always returns a null value:</p>
  
  <pre><code>controllerContext.Controller.ControllerContext.RouteData.Values[Name] = Argument;
  </code></pre>
  
  <p>Can anyone help.</p>