Using “data-toggle” with Html.ActionLink

最后都变了- 提交于 2019-11-29 15:57:47

问题


I want to use "data-toggle" wiht actionLink. Like this;

 Html.ActionLink("Delete", "Users", "Admin", new { item.UserId , strRole = strRole }, new { id = "cmdDelete", href="#myAlert",  data-toggle="modal" })

Unfortunately, doesn't accept. How can i use "data-toggle" like standart links?


回答1:


You can't. But there is a simple work-around. What you do is, replace the - with a _. During runtime it will get converted to a dash (-). So;

Html.ActionLink("Delete", "Users", "Admin", new { item.UserId , strRole = strRole }, new { id = "cmdDelete", href="#myAlert",  data_toggle="modal" })



回答2:


     @Html.ActionLink("TextLink", "ActionName", new { id = id }, new { @class = "btn btn-primary", data_toggle = "modal", data_target="#exampleModal" })


来源:https://stackoverflow.com/questions/12976120/using-data-toggle-with-html-actionlink

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!