这有效
<a href="@Url.Action("edit", "markets", new { id = 1 })"
data-rel="dialog" data-transition="pop" data-icon="gear" class="ui-btn-right">Edit</a>
但这不是。为什么?
@Html.ActionLink("Edit", "edit", "markets", new { id = 1 }, new {@class="ui-btn-right", data-icon="gear"})
看来你不能通过类似的东西data-icon="gear"
into htmlAttributes
?
建议?
问题是你的匿名对象属性data-icon
名称无效。 C# 属性的名称中不能包含破折号。有两种方法可以解决这个问题:
使用下划线代替破折号(MVC 将在发出的 HTML 中自动将下划线替换为破折号):
@Html.ActionLink("Edit", "edit", "markets",
new { id = 1 },
new {@class="ui-btn-right", data_icon="gear"})
使用接受字典的重载:
@Html.ActionLink("Edit", "edit", "markets",
new { id = 1 },
new Dictionary<string, object> { { "class", "ui-btn-right" }, { "data-icon", "gear" } });
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)