title: Submit Data from partial view to a controller MVC
body: <p>I have a list of employment records, you can also add an employment record from the same page using a partial view.</p>
  
  <p>Heres employment.cshtml that has a partial view for the records list and a partial view to add a new record which appears in a modal pop up.</p>
  
  <pre><code>&lt;h2&gt;Employment Records&lt;/h2&gt;
  
    @{Html.RenderPartial("_employmentlist", Model);}                              
  
  &lt;p&gt;
  &lt;a href="#regModal" class="btn btn_b" rel="fancyReg"&gt;Add New Record&lt;/a&gt;
  &lt;/p&gt;
  
  &lt;div style="display:none"&gt;
      &lt;div id="regModal"&gt; 
                @{Html.RenderPartial("_AddEmployment", new ViewModelEmploymentRecord());}     
  
                          &lt;/div&gt;
                      &lt;/div&gt;
  </code></pre>
  
  <p>Heres the partial view _AddEmployment.cshtml</p>
  
  <pre><code>@using (Html.BeginForm("AddEmployment, Application"))
  {                   
  @Html.ValidationSummary(true)
  
  &lt;div class="formEl_a"&gt;
  
  &lt;fieldset&gt;
      &lt;legend&gt;&lt;/legend&gt;
  
       &lt;div class="sepH_b"&gt;
  
              &lt;div class="editor-label"&gt;
                  @Html.LabelFor(model =&gt; model.employerName)
              &lt;/div&gt;
  
           etc....etc....
  
  &lt;/fieldset&gt;
  
  &lt;/div&gt;
    &lt;p&gt;
          &lt;input type="submit" class="btn btn_d" value="Add New Record" /&gt;
  
      &lt;/p&gt;
  
  
  }
  </code></pre>
  
  <p>and heres my Application controller:</p>
  
  <pre><code>[HttpPost]
      public ActionResult AddEmployment(ViewModelEmploymentRecord model)
      {
          try
          {
              if (ModelState.IsValid)
              {
  
                  Add Data.....
              }
          }
          catch
          {
  
          }
  
          return View(model);
      }
  </code></pre>
  
  <p>When compiling the following html is generated for the form:</p>
  
  <pre><code>&lt;form action="/Application/Employment?Length=26" method="post"&gt; 
  </code></pre>
  
  <p>It brings in a length string? and is invoking the Employment controller instead?</p>
  
  <p>Hope all is clear....</p>
  
  <p><strong>QUESTION ONE:</strong> when I click the submit button from within the partial view it does not go to the controller specified to add the data. Can anyone see where im going wrong?</p>
  
  <p><strong>QUESTION TWO:</strong> When I get this working I would like to update the employment list with the new record....am I going about this the correct way? Any tips appreciated.</p>