title: submit inside partial view - mvc4
body: <p>How can i trigger the <code>submit</code> button from partial view without using <code>Html.BeginForm</code> tag in Partial View. Reason being when there are two form tags, that is in main view and partial view, the validation doesn't work.    </p>
  
  <p>The important thing is that I want the validation to work.</p>
  
  <p>My Partial View code:    </p>
  
  <pre><code>&lt;div id="AddMe"&gt;
      &lt;div class="row"&gt;
          @Html.LabelFor(model =&gt; model.FirstName)
          @Html.TextBoxFor(model =&gt; model.FirstName)
          @Html.ValidationMessageFor(model =&gt; model.FirstName) // this should work
      &lt;/div&gt;     
  &lt;/div&gt;
  &lt;div&gt;
      &lt;input name="submit" type="submit" id="submit" value="Save" /&gt; // how do i trigger this from partial view
  &lt;/div&gt;
  </code></pre>
  
  <p>My Main View code:    </p>
  
  <pre><code>@using (Html.BeginForm("ActionName", "ControllerName", FormMethod.Post))
  {
      &lt;div class="modal" id="modalId" role="dialog"&gt;
       &lt;div class="modal-dialog"&gt;
          &lt;div class="modal-content"&gt;
              &lt;div class="modal-header"&gt;
  
              &lt;/div&gt;
              &lt;div class="modal-body" id="modalbodyId"&gt;
                  @Html.Partial("PartilViewName")
              &lt;/div&gt;
              &lt;div class="modal-header"&gt;
                   &lt;button type="submit"&gt;  
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
     &lt;/div&gt;
  }
  
  For Validation purpose, I have added the following lines of code in Main View.    
  
  $("#modalId").click(function () {
          var form = $("#modalbodyId").closest("form");
          form.removeData('validator');
          form.removeData('unobtrusiveValidation');
          $.validator.unobtrusive.parse(form);
  
          $.ajax({
              url: "/ControllerName/ActionName",
              type: "POST",
              data: $("#modalbodyId").serialize(),
              cache: false
          });
  
  
      });
  </code></pre>
  
  <p>Also just for the records all the models and other Annotations are in place.    </p>
  
  <blockquote>
    <p>Note: Do i need to add the <code>unobtrusive/ajax</code> code inside Partial View.</p>
  </blockquote>