title: My partial View is not showing error on validation and also on error my both view is getting opened up
body: <p>I am facing problem in validation in  two of my partial view</p>
  
  <p><strong>_partialA.cshtml</strong></p>
  
  <pre><code>@model demo3.Models.ModelA
  
     @using (Html.BeginForm("TEST", "Home"))    {
  
  &lt;h2&gt;_partialA&lt;/h2&gt;
  &lt;div&gt;
       @Html.EditorFor(m =&gt; m.EmployeeId)  
       @Html.ValidationMessageFor(m =&gt; m.EmployeeId) 
  &lt;/div&gt;
  &lt;div&gt;
       @Html.EditorFor(m =&gt; m.EmployeeName)
       @Html.ValidationMessageFor(m =&gt; m.EmployeeName) 
  &lt;/div&gt;
   &lt;input class="mainbutton" type="submit" value="TEST"/&gt;&lt;br /&gt;
   }
  </code></pre>
  
  <p>and another partial view is this</p>
  
  <p><strong>_partialB.cs.html</strong></p>
  
  <pre><code> @model demo3.Models.ModelB
        @using (Html.BeginForm("CreateAgreement", "Home"))
              {
  
  &lt;h2&gt;_partialB&lt;/h2&gt;
  &lt;div&gt;
      @Html.EditorFor(m =&gt; m.Comapny)
      @Html.ValidationMessageFor(m =&gt; m.Comapny)
  &lt;/div&gt;
  &lt;div&gt;
      @Html.EditorFor(m =&gt; m.FisacalYear)
      @Html.ValidationMessageFor(m =&gt; m.FisacalYear)  &lt;/div&gt;
    &lt;input class="mainbutton" type="submit" value="CreateAgreement"/&gt;&lt;br /&gt;
   }
  </code></pre>
  
  <p>This is my controller code</p>
  
  <pre><code> [HttpPost]
      public ActionResult CreateAgreement(ModelB modelb)
      {
          if (ModelState.IsValid)
          {
              return View("Start", modelb);
          }
          return View("Start", modelb);
      }
      [HttpPost]
      public ActionResult TEST(ModelA modela)
      {
          if (ModelState.IsValid)
          {
              return View("Start", modela);
          }
          return View("Start", modela);
      }
      public ActionResult Start()
      {
          return View();
      }
      public ActionResult FirstView()
      {
          ModelA objA = new ModelA();
          return PartialView("_partialA", objA);
      }
      public ActionResult SecondView()
      {
          ModelB objB = new ModelB();
          return PartialView("_partialB", objB);
      }
  </code></pre>
  
  <p>Now i am not getting any error message on click of button..and another thing..is my both view are getting opened up..on click of button..how to prevent that?</p>