Question

I have written my own HtmlHelper and now want to integrate Unobtrusive Validation (e.g. http://bradwilson.typepad.com/blog/2010/10/mvc3-unobtrusive-validation.html)

Is there a quick way to do this, to save interrogating the Model's Property's attributes and adding the data-val-etc HTML attributes to the HTML string that is built?

Was it helpful?

Solution

The GetUnobtrusiveValidationAttributes() method is used in the MVC3 source:

See:

OTHER TIPS

Appending the output of Html.ValidateFor() for the specific field should take care of it. Generally the ValidateFor() just outputs the validation logic and messages for a specific field. I may be missing something based on how I interpreted your question, but if I understand correctly that should solve it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top