I am attempting to add unobtrusive JavaScript to a file upload input control, using a custom HTML Helper extension. However, I have checked various blogs which use different methods to create the control, such as tab-builder but I couldn't find out how the unobtrusive data tags are added.
2 Answers
Unobtrusive data tags mainly means using the HTML 5 extensible "data-" attribute.
Check this blog post of Brad Wilson about unobtrusive javascript in MVC 3, he describes the various attributes used by the unobtrusive framework.
2 Comments
Extrakun
How do I get the validation function to call? For example, the required attribute will add data-val-required to the input. When building my own custom HtmlHelper, how do I know what attribute has been set on the input?
Sergi Papaseit
@Extrakun - Won't you be setting it yourself using the Tag Builder? Maybe I'm not following completely, have you started on some code that you can show?