title: asp.net mvc3 jquery ui dialog and client validation
body: <p>I have problem with client validation in asp.net mvc3 application.</p>
  
  <p>My code looks :</p>
  
  <pre><code>function loadEditCategoryDialog(categoryId) {
      $.ajax({
          url : "/rovastamp3/Admin/CategoryEditDialog",
          data : "categoryId="+categoryId,
          success : function(data){
              $("#popup_dialog").html(data);
              $("#popup_dialog").dialog({        
                  modal: true,
                  draggable: false,
                  resizable: false,
                  title: "Upravit kategorii",
                  width: 600,
                  height: 500,
              });                             
          }
      });
   }
  </code></pre>
  
  <p>Controller : </p>
  
  <pre><code>[HttpGet]
  public ActionResult CategoryEditDialog(int categoryId)
  {
      CategoryEditViewModel categoryEditViewModel = new CategoryEditViewModel();
      categoryEditViewModel.Category = _postAuctionCategoryRepo.Query()
          .SingleOrDefault(x =&gt; x.Id == categoryId);
  
      return PartialView(categoryEditViewModel);
  }
  
  [HttpPost]
  public ActionResult CreateNewCategory(CategoryEditViewModel categoryEditViewModel)
  {
      if (ModelState.IsValid)
      {
          return RedirectToAction("Index");
      }
      return View("CategoryEditDialog", categoryEditViewModel);
  }
  </code></pre>
  
  <p>And finally my partial view : </p>
  
  <pre><code>@model Rovastamp.MVC3.ViewModels.AdminController.CategoryEditViewModel
  &lt;h2&gt;Upravit kategorii @Model.Category.Name&lt;/h2&gt;
  @{Html.EnableClientValidation();}
  @using (Html.BeginForm("CreateNewCategory", "Admin"))
  { 
      @Html.ValidationSummary(true)
      &lt;fieldset&gt;
          &lt;legend&gt;Objednávkový formulář&lt;/legend&gt;
  
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.Category.Name) 
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.TextBoxFor(model =&gt; model.Category.Name) 
              @Html.ValidationMessageFor(model =&gt; model.Category.Name) 
          &lt;/div&gt;
  
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(model =&gt; model.Category.Position) 
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.TextBoxFor(model =&gt; model.Category.Position) 
              @Html.ValidationMessageFor(model =&gt; model.Category.Position) 
          &lt;/div&gt;
  
          &lt;input  type="submit" value="Upravit" class="submit_button" /&gt;               
      &lt;/fieldset&gt;
  }
  </code></pre>
  
  <p>In my web.config I turned on UnobtrusiveJavaScript and ClientValidatin app settings.</p>
  
  <p>If I clik on submit button on jquery ui dialog, mvc does full refresh without client validation?</p>
  
  <p>Where is the problem?</p>
  
  <p>Thanks for any help</p>
  
  <p>EDIT : </p>
  
  <p>In my Layout page i include this scripts :</p>
  
  <ul>
  <li>jquery.unobtrusive-ajax.js</li>
  <li>jquery.validate.js</li>
  <li>jquery.validate.unobtrusive.js</li>
  </ul>
  
  <p>EDIT 2</p>
  
  <p>In my exemaple i put :</p>
  
  <pre><code>jQuery.validator.unobtrusive.parse('#popup_dialog');
  </code></pre>
  
  <p>before i call jquery ui dialog and client validation works perfectly.</p>