title: Html.ValidationMessageFor in partial view(ASP.NET MVC3)
body: <p>Currently I have a partial view with a textbox and a ValidationMessageFor.  This works fine and the message displays as expected when the input is not valid.  I'm doing a little HTML refactoring and I want to bump up the validationMessageFor up to the view that currently contains the partial view.  I almost have it working correctly but there is a couple of snags.  </p>
  
  <pre><code>@Html.ValidationMessageFor(m =&gt; m.Mileage, string.Empty, new { id = "spanMileageError", @class = "mileageErrorSpanClass" }) 
  </code></pre>
  
  <p>The model for this view is a vehicle object.  The model for the partialView is a slightly different object</p>
  
  <pre><code>@Html.TextBoxFor(v =&gt; v.Vehicle.Mileage, new { placeHolder = mileagePlaceHolderText, id = Model.TextBoxId, maxlength = "7", @class="mileageTextBoxClass" })       
  </code></pre>
  
  <p>This configuration gives a name to the textbox ("Vehicle.Mileage") but the Validation attribute ("data-valmsg-for") is equal to "Mileage" and not "Vehicle.Mileage".</p>
  
  <p>How can I correct the ValidationMessageFor helper to emit the correct HTML to make this validation work?  </p>
  
  <p>Here is the rendered HTML of the current view prior to the HTML refactor</p>
  
  <pre><code>&lt;input type="text" value="" placeholder="Enter Mileage" name="Vehicle.Mileage"     maxlength="7" id="textBoxMileage" data-val-range-min="1" data-val-range-max="999999" data-    val-range="Mileage must be a valid number between 1 and 999,999." data-val-number="The     field Mileage must be a number." data-val="true" class="mileageTextBoxClass input-    validation-error" autocomplete="off"&gt;
  
  &lt;span id="spanMileageError" data-valmsg-replace="true" data-valmsg-for="Vehicle.Mileage" class="mileageErrorSpanClass field-validation-error"&gt;&lt;span htmlfor="textBoxMileage" generated="true" class=""&gt;Mileage must be a valid number between 1 and 999,999.&lt;/span&gt;&lt;/span&gt;
  </code></pre>
  
  <p>And here is the HTML after the refactor</p>
  
  <pre><code>&lt;input type="text" value="" placeholder="Enter Mileage" name="Vehicle.Mileage" maxlength="7" id="textBoxMileage" data-val-range-min="1" data-val-range-max="999999" data-val-range="Mileage must be a valid number between 1 and 999,999." data-val-number="The field Mileage must be a number." data-val="true" class="mileageTextBoxClass placeholder" autocomplete="off"&gt;
  &lt;span id="spanMileageError" data-valmsg-replace="true" data-valmsg-for="Mileage" class="field-validation-valid mileageErrorSpanClass"&gt;&lt;/span&gt;
  </code></pre>
  
  <p>Notice the span is missing the inner span element that used to be present.  Can anyone help me correct the problem here? </p>
  
  <p>Thanks for any tips and tricks or possible solutions.
  Cheers,<br>
  ~ck in San Diego</p>