title: asp net mvc partial view validation
body: <p>Hi how are you? I'm trying to validate a form in ASP NET MVC.</p>
  
  <p>I have a partial view "Address" that I reuse for some entities, like Company, Person, etc.</p>
  
  <p>My problem is that when I submit the form, only the controls of the father view gets validated, the ones in the partial view don't.</p>
  
  <p>Here's some code I hope u can geive me hand</p>
  
  <p><strong>PERSON VIEW</strong></p>
  
  <pre><code>@model Entities.Person
  
  
  @using (Html.BeginForm("Create", "Person", FormMethod.Post))
  {
  
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  @Html.LabelFor(model =&gt; model.FirstName)
                  &lt;div class="control"&gt;
                      @Html.TextBoxFor(model =&gt; model.FirstName, new { @maxlength = 7, @class = "numeric"})
                      @Html.ValidationMessageFor(model =&gt; model.FirstName)
                  &lt;/div&gt;
                  &lt;div class="spacer-short"&gt;&lt;/div&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.LabelFor(model =&gt; model.LastName)
                  &lt;div class="control"&gt;
                      @Html.TextBoxFor(model =&gt; model.LastName, new { @maxlength = 7, @class = "numeric"})
                      @Html.ValidationMessageFor(model =&gt; model.LastName)
                  &lt;/div&gt;
                  &lt;div class="spacer-short"&gt;&lt;/div&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
      @{ Html.RenderAction("Index", "Address", new {id = Model.AddressId});} //Renders the Address form part
  
      &lt;div class="spacer"&gt;&lt;/div&gt;
      &lt;button type="submit" data-button="true" data-button-icon="ui-icon-disk" class=""&gt;Create&lt;/button&gt;
      &lt;button type="button" data-button="true" data-button-icon="ui-icon-circle-close" class="button-cancel"&gt;Cancel&lt;/button&gt;
  }
  </code></pre>
  
  <p><strong>ADDRESS VIEW</strong></p>
  
  <pre><code>@model Entities.Address
  
  
  &lt;table&gt;
       &lt;tr&gt;
           &lt;td&gt;
              @Html.LabelFor(model =&gt; model.Street)
              &lt;div class="control"&gt;
                  @Html.TextBox("Address.Street", Model.Street)
                  @Html.ValidationMessage("Address.Street")
               &lt;/div&gt;
             &lt;div class="spacer-short"&gt;&lt;/div&gt;
             &lt;/td&gt;
             &lt;td&gt;
                @Html.LabelFor(model =&gt; model.Number)
                &lt;div class="control"&gt;
                  @Html.TextBox("Address.Number", Model.Number)
                  @Html.ValidationMessage("Address.Number")
               &lt;/div&gt;
             &lt;div class="spacer-short"&gt;&lt;/div&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  </code></pre>
  
  <p>Then I have some validation metadata ([Required]) for person and address fields</p>