title: ASP.NET MVC 2 loading partial view using jQuery - no client side validation
body: <p>I am using <code>jQuery.load()</code> to render a partial view. This part looks like this:</p>
  
  <pre><code>$('#sizeAddHolder').load(
                  '/MyController/MyAction', function () { ... });
  </code></pre>
  
  <p>The code for actions in my controller is the following:</p>
  
  <pre><code>    public ActionResult MyAction(byte id)
      {
          var model = new MyModel
          {
              ObjectProp1 = "Some text"
          };
  
          return View(model);
      }
  
      [HttpPost]
      public ActionResult MyAction(byte id, FormCollection form)
      {
          // TODO: DB insert logic goes here
  
          var result = ...;
  
          return Json(result);
      }
  </code></pre>
  
  <p>I am returning a partial view that looks something like this:</p>
  
  <pre><code>&lt;% using (Html.BeginForm("MyAction", "MyController")) {%&gt;
      &lt;%= Html.ValidationSummary(true) %&gt;
  
      &lt;h3&gt;Create my object&lt;/h3&gt;
  
      &lt;fieldset&gt;
          &lt;legend&gt;Fields&lt;/legend&gt;
  
          &lt;div class="editor-label"&gt;
              &lt;%= Html.LabelFor(model =&gt; model.ObjectProp1) %&gt;
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              &lt;%= Html.TextBoxFor(model =&gt; model.Size.ObjectProp1) %&gt;
              &lt;%= Html.ValidationMessageFor(model =&gt; model.ObjectProp1) %&gt;
          &lt;/div&gt;
  
          div class="editor-label"&gt;
              &lt;%= Html.LabelFor(model =&gt; model.ObjectProp2) %&gt;
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              &lt;%= Html.TextBoxFor(model =&gt; model.ObjectProp2) %&gt;
              &lt;%= Html.ValidationMessageFor(model =&gt; model.ObjectProp2) %&gt;
          &lt;/div&gt;
  
          &lt;p&gt;
              &lt;input type="submit" value="Create" /&gt;
          &lt;/p&gt;
      &lt;/fieldset&gt;
  
  &lt;% } %&gt;
  </code></pre>
  
  <p>Client side validation does not work in this case. What is more the script that contains validation messages also isn't included in the view that's returned. Both properties in my model class have <code>Required</code> and <code>StringLength</code> attributes.
  Is there any way to trigger client side validation in a view which has been loaded like this?</p>