views:

31

answers:

1

I'd like to highlight field names instead of showing a separate error message when there is a validation error.

Is there any convenient way of doing this other than checking the ModelState Errors collection and wrapping each .LabelFor() in an if?

Also, I'd like to format labels as either bold, or add an asterisk if the model metadata has a [Required] attribute.

+1  A: 

You'll need use a custom Object.ascx file by creating either /Shared/DisplayTemplates/Object.ascx or /Shared/EditorTemplates/Object.ascx

I can't answer any better than this guide at Brad Wilson's blog: http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-4-custom-object-templates.html

jfar
Excellent link.
David Lively