开发者

MVC3 - Coding a custom HTML Helper which output works with unobtrusive Javascript

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 ho开发者_运维技巧w the unobtrusive data tags are added.


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.


If you are using TagBuilder, you can do this:

var validationAttributes = html.GetUnobtrusiveValidationAttributes(name, metadata);

then use MergeAttributes on your tagbuilder to add the unobtrusive validation attributes to your tag.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜