【问题标题】:ASP.NET MVC how to insert other html element inside @HTML.ActionLinkASP.NET MVC 如何在 @HTML.ActionLink 中插入其他 html 元素
【发布时间】:2014-04-14 09:08:46
【问题描述】:

通常,我会这样写:

<li>@Html.ActionLink("Dashboard", "Index", "Account")</li>

要生成这个:

<a href="/Account">Dashboard</a>

我想知道的是是否可以生成如下的HTML

<a href="#"><i class="fa fa-dashboard"></i> Dashboard</a>

无需创建我自己的自定义 TagBuilder 类。

感谢您的帮助。

【问题讨论】:

    标签: asp.net-mvc asp.net-mvc-4 c#-4.0 razor


    【解决方案1】:

    你可以使用UrlHelper.Action来生成url:

    <a href="@Url.Action("Index", "Account")">
        <i class="fa fa-dashboard"></i> Dashboard
    </a>
    

    【讨论】:

    • 感谢您的回答。
    猜你喜欢
    • 2014-05-27
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 2011-06-16
    • 2015-08-16
    • 2011-02-08
    • 2013-12-01
    • 1970-01-01
    相关资源
    最近更新 更多