HTML5允许使用以短语“data-”为前缀的自定义属性,它们通过验证而不使用自定义DTD(
more info)。在Asp.Net MVC中,有没有任何方法来指定一个带有data属性的ActionLink?
向ActionLink添加属性的典型方法是传递匿名对象,每个对象具有自定义属性:
new { customattribute="value" }
我想做的是:
new { data-customattribute="value" }
但这不工作,因为连字符字符在属性名称中无效。有什么办法绕过这个限制吗?或者我只需要在使用ActionLinks和使用数据属性之间进行选择?
解决方法
或者你可以使用
new {data_customattribute =“value”}
编译器足够聪明,能够知道你的意思
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。