title: Return Validation Error back to jQuery dialog in MVC 3
body: <p>Hi have a page that loads a jQuery modal dialog, the modal contains a form. How can i return an error so that it loads in the modal, if i return a PartialView, the page just loads with the dialog form contents (which is just intended to be in the modal)</p>
  
  <p>here is the view</p>
  
  <pre><code>&lt;span&gt;&lt;a id="end" href="#"&gt;Launch End Dialog&lt;/a&gt; &lt;/span&gt;
  
  
  
  &lt;div id="end-dialog" class="dialog"&gt;
    &lt;div id="end-inner"&gt;&lt;/div&gt;
    &lt;hr /&gt;
  &lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
    $(function () {
  
  
      var endDialog = $("#end-care-plan-dialog").dialog({
  
      });
  
      $("#end").click(function () {
        endDialog.dialog('close');
      });
  
      $('#end').click(function () {
        $('#end-inner').load(baseUrl + "/End", $.param({ id: '@Model.id' }),
                function () {
                  endDialog.dialog('open');
                });
      });
    });
  &lt;/script&gt;
  </code></pre>
  
  <p>heres my controller</p>
  
  <pre><code>[HttpPost]
  public ActionResult End(EndVM end)
  {
    if (ModelState.IsValid)
    {
      //do work
  
    }
  
    //return so that pop up now has validation errors
    return PartialView(end);
  }
  </code></pre>
  
  <p>Note - jquery.validate and jquery.validate.unobstrusive are loaded into the views</p>
  
  <p>Thanks hope this makes sense.</p>
  
  <p>Update: Diego - this is the partial view that contains the form (that is loaded into the moal)</p>
  
  <pre><code>@using (Html.BeginForm&lt;EndController&gt;(c =&gt; c.End(@Model.Id)))
  </code></pre>
  
  <p>{
    @Html.HiddenFor(m => m.Id)
    
      @Html.DropDownListFor(m => m.EndReasonId, RefData.EndReasons)
    
    
      Other Reason
      @Html.EditorFor(m => m.EndReasonOther)
      @Html.ValidationMessageFor(m => m.EndReasonOther)
    
    
      @(Html.ActionLink(c => c.Edit(@Model.Id), "Cancel")) @Html.SubmitButton("End", "End")
    
  }</p>
  
  <p>Is there where i adapt your code?</p>
  
  <p>Thanks</p>