Is there a good way of displaying required field indicators when using DataAnnotations in MVC 2?

Posted by Jeremy Gruenwald on Stack Overflow See other posts from Stack Overflow or by Jeremy Gruenwald
Published on 2010-04-23T21:07:06Z Indexed on 2010/04/23 21:13 UTC
Read the original article Hit count: 303

I've got validation working with DataAnnotations on all my models, but I'd like to display an indicator for required fields on page load. Since I've got all my validation centralized, I'd rather not hard-code indicators in the View. Calling validation on load would show the validation summary. Has anyone found a good way of letting the model determine what's required, but checking it upon rendering the view, similar to Html.ValidationMessageFor?

© Stack Overflow or respective owner

Related posts about dataannotations

Related posts about asp.net-mvc-2