There is an unsaved comment in progress. You will lose your changes if you continue. Are you sure you want to reopen the work item?
DropDownListFor() Unobtrusive Validation Problem
I have a project using MVC 3 RC and the Razor View engine.
I have several DropDownListFor() elements which are required. I set the [Required(..)] atribute for my model, but no unobtrusive validation is being emitted for the<select> elements. All other unobtrusive validation is being emitted as needed.
I can provide sample code if requested.
This is a critical issue for this project. Is it possible to address this issue before RTM?
I also have some custom HtmlHelpers which create markup (essentially a UserControl) where the user's input value is placed by client-side script into a hidden input. Unobtrusive validation is not being emitted for my hidden input element. This is also a very important issue for my project.
In the interim, I have written a hack into a custom HtmlHelper [DropDownListUovFor()] to read the FieldValidationMetadata ModelClientValidationRules, and add them directly as HTML5 attributes, which are then sent to the underlying DropDownListFor() helper. Voila, I have my unobtrusive validation for my DropDownList. Ugly (ok, ok VERY ugly), but functional. Also, the same ugly hack serves as a work-around for my other custom Htmlhelpers.