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开发者_StackOverflow the Model's Property's attributes and adding the data-val-etc
HTML attributes to the HTML string that is built?
The GetUnobtrusiveValidationAttributes()
method is used in the MVC3 source:
See:
- http://msdn.microsoft.com/en-us/library/gg416607(v=vs.98).aspx
- System.Web.Mvc.Html.InputExtensions.cs:371
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.
精彩评论