问题
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