title: MVC 3 Remote Validation Form Button Not Included in POST Data
body: <p>I have an ASP.NET MVC3 app and with remote validation on one of my model classes. I discovered if I open the Edit view for the that model and the remote validation routine <strong>IS NOT</strong> called (due to not editing the field with remote validation on it) before submitting the form, the button clicked to POST the form <strong>IS NOT</strong> included in the request data sent to the Action method. </p>
  
  <p>If the remote validation routine <strong>IS</strong> called before the form is POSTed - the button clicked to submit the form <strong>IS</strong> included in the POST.</p>
  
  <p>I need to know which button was clicked when the Action is called on the server so I can determine if the user clicked UPDATE or CANCEL.</p>
  
  <p>If I remove the remote validation from the model the form submits correctly every time.</p>
  
  <p>Why would the button that was used to submit the form be excluded from the form post when remote validation is not called prior to the form submission.</p>
  
  <p>thanks
  Michael</p>
  
  <p>Here is some sample code:</p>
  
  <pre><code>@model Channel
  &lt;script src="@Url.Content("~/Scripts/jquery-1.6.1.min.js")" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"&gt;&lt;/script&gt;
  
  @using (Html.BeginForm()) {
  &lt;fieldset&gt;
      &lt;legend&gt;Edit Channel&lt;/legend&gt;
  
      @Html.HiddenFor(model =&gt; model.ChannelGUID)
  
  
      &lt;div class="editor-label"&gt;Name&lt;/div&gt;
      &lt;div class="editor-field"&gt;
          @Html.EditorFor(model =&gt; model.Name)
          @Html.ValidationMessageFor(model =&gt; model.Name)
      &lt;/div&gt;
  
      &lt;div class="editor-label"&gt;Description&lt;/div&gt;
      &lt;div class="editor-field"&gt;
          @Html.EditorFor(model =&gt; model.Description)
          @Html.ValidationMessageFor(model =&gt; model.Description)
      &lt;/div&gt;
  
      &lt;div class="editor-label"&gt;Channel Code&lt;/div&gt;
      &lt;div class="editor-field"&gt;
          @Html.EditorFor(model =&gt; model.Code)
          @Html.ValidationMessageFor(model =&gt; model.Code)
      &lt;/div&gt;
  
      &lt;p&gt;
          &lt;button type="submit" name="updateCommand" value="Update"&gt;Update&lt;/button&gt;
          &lt;button type="submit" class="cancel"&gt;Cancel&lt;/button&gt;
      &lt;/p&gt;
  &lt;/fieldset&gt;
  }
  </code></pre>
  
  <p>here is the action</p>
  
  <pre><code>[HttpPost]
  public ActionResult Edit(string updateCommand, Channel channel)
  {
      if (updateCommand != null)
      {
       //update clicked
      }
      else
      {
       //cancel clicked
      }
  </code></pre>
  
  <p>here is the remote attribute on the model property Code</p>
  
  <pre><code>[Remote("IsChannelCodeUnique", "Channel", AdditionalFields = "ChannelGUID", ErrorMessage = "code must be unique")]
  </code></pre>