title: razor validation in partialview and ajax form not working
body: <p>I have the following PartialView</p>
  
  <pre><code>@model Token.Creator.Site.Models.Customer
  @{
      var cusModel = new Token.Creator.Site.Models.CustomerModel();
      ViewContext.FormContext = new FormContext();
      HtmlHelper.ClientValidationEnabled = true;
      HtmlHelper.UnobtrusiveJavaScriptEnabled = true;
  }
  &lt;div class="modal fade" id="customereditmodal" tabindex="-1" role="dialog" aria-hidden="true"&gt;
      @using (Ajax.BeginForm("EditCustomer", "Customer", new AjaxOptions(), new {
          @class = "modal-dialog form-horizontal",
          id = "upload_s0pin"
      })) { 
          &lt;div class="modal-content"&gt;
              &lt;div class="modal-header"&gt;
                  &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;&amp;times;&lt;/button&gt;
                  @if (string.IsNullOrEmpty(Model.Companyname)) { 
                      &lt;h4 class="modal-title"&gt;@Model.Gender.Type @Model.Title @Model.Firstname @Model.Lastname&lt;/h4&gt;
                  } else {
                      &lt;h4 class="modal-title"&gt;@Model.Companyname&lt;/h4&gt;
                  }
              &lt;/div&gt;
              &lt;div class="modal-body"&gt;
                  @Html.ValidationSummary()
                  &lt;div class="form-group"&gt;
                      @Html.LabelFor(cus =&gt; cus.Companyname, "Firmenname", new { @class = "col-lg-3 control-label" })
                      &lt;div class="col-lg-9"&gt;
                          @Html.TextBoxFor(cus =&gt; cus.Companyname, new { @class = "form-control" })
                      &lt;/div&gt;
                      @Html.ValidationMessageFor(cus =&gt; cus.Companyname);
                  &lt;/div&gt;
                  &lt;h4&gt;Ansprechpartner&lt;/h4&gt;
                  &lt;div class="form-group"&gt;
                      @Html.LabelFor(cus =&gt; cus.Gender, "Anrede*", new { @class = "col-lg-3 control-label" })
                      &lt;div class="col-lg-9"&gt;
                          @Html.DropDownListFor(cus =&gt; cus.Gender, new SelectList(cusModel.Gender.ToList(), cusModel.Gender), new { @class = "form-control" })
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                      @Html.LabelFor(cus =&gt; cus.Title, "Titel", new { @class = "col-lg-3 control-label" })
                      &lt;div class="col-lg-9"&gt;
                          @Html.TextBoxFor(cus =&gt; cus.Title, new { @class = "form-control" })
                      &lt;/div&gt;
                      @Html.ValidationMessageFor(cus =&gt; cus.Title);
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                      @Html.LabelFor(cus =&gt; cus.Firstname, "Vorname*", new { @class = "col-lg-3 control-label" })
                      &lt;div class="col-lg-9"&gt;
                          @Html.TextBoxFor(cus =&gt; cus.Firstname, new { @class = "form-control" })
                      &lt;/div&gt;
                      @Html.ValidationMessageFor(cus =&gt; cus.Firstname);
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                      @Html.LabelFor(cus =&gt; cus.Lastname, "Nachname*", new { @class = "col-lg-3 control-label" })
                      &lt;div class="col-lg-9"&gt;
                          @Html.TextBoxFor(cus =&gt; cus.Lastname, new { @class = "form-control" })
                      &lt;/div&gt;
                      @Html.ValidationMessageFor(cus =&gt; cus.Lastname);
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                      @Html.LabelFor(cus =&gt; cus.Emailaddress, "Emailadresse*", new { @class = "col-lg-3 control-label" })
                      &lt;div class="col-lg-9"&gt;
                          @Html.TextBoxFor(cus =&gt; cus.Emailaddress, new { @class = "form-control" })
                      &lt;/div&gt;
                      @Html.ValidationMessageFor(cus =&gt; cus.Emailaddress);
                  &lt;/div&gt;
                  &lt;h4&gt;Adresse&lt;/h4&gt;
                  &lt;div class="form-group"&gt;
                      @Html.LabelFor(cus =&gt; cus.Street, "Straße und Hausnummer*", new { @class = "col-lg-3 control-label" })
                      &lt;div class="col-lg-9"&gt;
                          @Html.TextBoxFor(cus =&gt; cus.Street, new { @class = "form-control" })
                      &lt;/div&gt;
                      @Html.ValidationMessageFor(cus =&gt; cus.Street);
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                      @Html.LabelFor(cus =&gt; cus.ZIPCode, "Postleitzahl*", new { @class = "col-lg-3 control-label" })
                      &lt;div class="col-lg-9"&gt;
                          @Html.TextBoxFor(cus =&gt; cus.ZIPCode, new { @class = "form-control" })
                      &lt;/div&gt;
                      @Html.ValidationMessageFor(cus =&gt; cus.ZIPCode);
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                      @Html.LabelFor(cus =&gt; cus.Town, "Stadt*", new { @class = "col-lg-3 control-label" })
                      &lt;div class="col-lg-9"&gt;
                          @Html.TextBoxFor(cus =&gt; cus.Town, new { @class = "form-control" })
                      &lt;/div&gt;
                      @Html.ValidationMessageFor(cus =&gt; cus.Town);
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                      @Html.LabelFor(cus =&gt; cus.Country, "Land*", new { @class = "col-lg-3 control-label" })
                      &lt;div class="col-lg-9"&gt;
                          @Html.TextBoxFor(cus =&gt; cus.Country, new { @class = "form-control" })
                      &lt;/div&gt;
                      @Html.ValidationMessageFor(cus =&gt; cus.Country);
                  &lt;/div&gt;
                  &lt;div class="modal-footer"&gt;
                      &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Schließen&lt;/button&gt;
                      &lt;input type="submit" class="btn btn-primary" value="Speichern" /&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      }
  &lt;/div&gt;
  </code></pre>
  
  <p>The modelclass is autogenerated by EF. And I extend it to apply validation attributes.</p>
  
  <pre><code>[MetadataType(typeof(CustomerMetadata))]
  public partial class Customer {
      private class CustomerMetadata {
          [Required(ErrorMessage = "Geben Sie einen Vornamen ein")]
          public object Firstname;
          [Required(ErrorMessage = "Geben Sie einen Nachnamen ein")]
          public object Lastname;
          [Required(ErrorMessage = "Geben Sie eine Straße ein")]
          public object Street;
          [Required(ErrorMessage = "Geben Sie eine Postleitzahl ein")]
          public object ZIPCode;
          [Required(ErrorMessage = "Geben Sie eine Stadt ein")]
          public object Town;
          [Required(ErrorMessage = "Geben Sie ein Land ein")]
          public object Country;
          [Required]
          [DataType(DataType.EmailAddress, ErrorMessage = "Bitte geben Sie eine gültige Emailadresse ein")]
          public object Emailaddress;
      }
  }
  </code></pre>
  
  <p>But the validation doesn't work. What am I doing wrong?</p>
  
  <p>EDIT: <strong>The partial view is loaded by AJAX</strong></p>