I am noticing a weird issue when using ModelState.AddModelError to validate input on my forms. The output from Html.ValidationMessage is not the true HTML value but it's encoded value and so the CSS style is not applied to the error message.
Example:
private string errorMessage = "<span class="negative">{0}</span><br class="hid" />";
ModelState.AddModelError("title", String.Format(errorMessage, "Tab title is required"));
The output is shown as:
<span class="field-validation-error"><span class="negative">URL is Required</span><br class="hid" /></span>
This didn't use to be the case with their earlier beta's and I am not sure what approach to take here.
Thanks Nick
See Question&Answers more detail:os