title: Ajax form with different actions in ASP MVC
body: <p>In ASP.NET MVC I have the following input form (simplified):</p>
  
  <pre><code>&lt;div id="ajaxtarget"&gt;
  @using (Ajax.BeginForm("SubmitForm", "Home", new AjaxOptions { UpdateTargetId = "ajaxtarget" }))
  {
          @Html.DropDownListFor(x =&gt; x.PostalCode, Model.PostalCodeItemList, new { @name = "PostalCodeId" , @id="PostalCodeId" })
  
          @Html.LabelFor(x =&gt; x.StreetCode)
          @Html.DropDownListFor(x =&gt; x.StreetCode, Model.StreetItemList, new {  @id="StreetCodeId" })
  
          ...
          &lt;input type="submit" value="@Global.Execute" id="btnSubmit" /&gt;
  }
  &lt;/div&gt;
  </code></pre>
  
  <p>When the user selects something from the first dropdownlist, the second dropdownlist should be populated via AJAX. I can send 'call' my controller via javascript to update my view:</p>
  
  <pre><code>$(document).ready(function () {
          $('#PostalCodeId').on('change', function () {
              $(this).parents('form').submit();
          });
      });
  </code></pre>
  
  <p>My problem is that my form has a lot of different controls that trigger some action I need to handle in my controller, so I'm looking for a way to add some extra parameters when I submit my form. </p>
  
  <p>Right now I found a solution where I add an extra field in my model and in my form that I populate in javascript depending on which control fires the script. <code>@Html.HiddenFor(x =&gt; x.ChosenControllerAction, new { id = "ChosenAction" })</code> In my controller I can return a view or action based on this value:</p>
  
  <pre><code>    public ActionResult SubmitForm(MyModel model) 
      {
          if (model.ChosenControllerAction == "PopulateStreetCodes")
          {
            ...
          }
  </code></pre>
  
  <p>I'm sure there must be a different/better way to archieve what I want to do. What's the right way to return the correct ActionResults in a complex <em>self updating</em> ajax form?</p>