C# 在 Html.ActionLink 中使用“数据切换”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12976120/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 01:10:20  来源:igfitidea点击:

Using "data-toggle" with Html.ActionLink

c#asp.net-mvc-4html.actionlink

提问by nermik

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

我想使用带有 actionLink 的“数据切换”。像这样;

 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?

可惜不接受。我如何像标准链接一样使用“数据切换”?

回答by Nickvda

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" })

回答by Anderson Costa

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