gpt4 book ai didi

asp.net-mvc - 将 html 属性传递给 Html.Actionlink 辅助函数

转载 作者:行者123 更新时间:2023-12-04 23:22:43 24 4
gpt4 key购买 nike

我想知道如何将 html 属性传递给 @Html.ActionLink辅助功能

我想那样做

<a class="accordion-toggle" data-toggle="collapse" data-parent="#leftMenu" href="/Admin/UserManagment">
<i class="icon-user"></i>User Managment
</a>

如何传递斜体 html 属性

最佳答案

您可以使用 @Url.Action()作为备选。

在这种情况下,您的代码将如下所示:

<a class="accordion-toggle" data-toggle="collapse" data-parent="#leftMenu" 
href="@Url.Action("UserManagment", "Admin")">
<i class="icon-user"></i>User Managment
</a>

编辑:

出于兴趣,我做了一些研究,发现 this answer .这解释了不可能使用 Html.ActionLink以此目的:

The Html.ActionLink helper HTML encodes the link text which prevents you from embedding HTML in the link text.

关于asp.net-mvc - 将 html 属性传递给 Html.Actionlink 辅助函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19788481/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com