title: How to display a model state error in case I am returning a partial view
body: <p>I have the following action method for creating new network info:-</p>
  
  <pre><code>public ActionResult CreateVMNetwork(int vmid)
          {
  VMAssignIps vmips = new VMAssignIps()
  {
  TechnologyIP = new TechnologyIP() { TechnologyID = vmid},
  IsTMSIPUnique = true,
  IsTMSMACUnique = true
  };
              return PartialView("_CreateVMNetwork",vmips);
  }
  
  
   [HttpPost]
      public ActionResult CreateVMNetwork(VMAssignIps vmip)
      {
          if (ModelState.IsValid)
          {
              try
              {
                  repository.InsertOrUpdateVMIPs(vmip.TechnologyIP,User.Identity.Name);
                  repository.Save();
              return PartialView("_networkrow",vmip);
  
          }
          catch (Exception ex)
          {
  
              ModelState.AddModelError(string.Empty, "Error occurred: " + ex.InnerException.Message);
          }
  
      }
      return PartialView("_CreateVMNetwork", vmip);
  
  }
  </code></pre>
  
  <p>And I have the following _CreateVMNetwork view:-</p>
  
  <pre><code>@model TMS.ViewModels.VMAssignIps
  @using (Ajax.BeginForm("CreateVMNetwork", "VirtualMachine", new AjaxOptions
  
  {
      InsertionMode = InsertionMode.InsertAfter,
      UpdateTargetId = "networktable",
      LoadingElementId = "loadingimag",
      HttpMethod= "POST"
  }))
  {
         @Html.ValidationSummary(true)
         @Html.HiddenFor(model=&gt;model.TechnologyIP.TechnologyID)
      @Html.Partial("_CreateOrEditVMNetwork", Model)
  
         &lt;input type="submit" value="Save" class="btn btn-primary"/&gt;
  }
  </code></pre>
  
  <p>and _CreateOrEditVMNetwork view:- </p>
  
  <pre><code>@model TMS.ViewModels.VMAssignIps
  
  &lt;div&gt;
  &lt;span class="f"&gt;IP Address&lt;/span&gt; 
  
  @Html.EditorFor(model =&gt; model.TechnologyIP.IPAddress)
  @Html.ValidationMessageFor(model =&gt; model.TechnologyIP.IPAddress)                                              
  
     &lt;input type="CheckBox" name="IsTMSIPUnique" value="true" @(Html.Raw(Model.IsTMSMACUnique ? "checked=\"checked\"" : "")) /&gt; | 
   &lt;span class="f"&gt; MAC Address&lt;/span&gt;       
  @Html.EditorFor(model =&gt; model.TechnologyIP.MACAddress)
  @Html.ValidationMessageFor(model =&gt; model.TechnologyIP.MACAddress)                                              
  
   &lt;input type="CheckBox" name="IsTMSMACUnique" value="true" @(Html.Raw(Model.IsTMSMACUnique ? "checked=\"checked\"" : "")) /&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>The problem I am facing is that in case there is a model state error when adding a new entity, a partial view will be displayed with the model state error as follow:-
  <img src="https://i.stack.imgur.com/qFuQl.png" alt="enter image description here"></p>
  
  <p>So my question is , if there is a way to display the model state error with the partial view , without updating the table row “insert after” as I am doing currently?
  Thanks</p>