我如何将css应用于MVC中的actionlink

时间:2014-03-25 06:36:00

标签: asp.net-mvc twitter-bootstrap fonts

以下是我的HTML链接 <a href="index.html"><i class="fa fa-dashboard fa-fw"></i> Dashboard</a>

如何使用CSS(<i>标记)将上述内容转换为以下操作链接 @Html.ActionLink("AppStore", "Index", "Home")

请帮助..

4 个答案:

答案 0 :(得分:1)

你可以这样做

@ Html.ActionLink(&#34; Name&#34;,&#34; viewname&#34;,&#34; Controllername&#34;,new {HTML Attributes here})

@Html.ActionLink("AppStore", "Index", "Home", new {@class="fa fa-dashboard fa-fw"})

答案 1 :(得分:0)

以下功能告诉您如何在动作链接调用中添加css。

@Html.Action("AppStore", "Index", "Home", New With {.class="cssvalue"})

以上语法为vb.net

答案 2 :(得分:0)

如果您想在anchor标记内使用html标记,请使用Url.Action

<a href="@Url.Action("Index", "Home") "><i class="fa fa-dashboard fa-fw"></i>Dashboard</a>
Html.Actionlink的{​​p> Correct overload

//linkText, actionName, controllerName, routeValues, htmlAttributes
@Html.ActionLink("AppStore", "Index", "Home", new object{}, new {class="fa fa-dashboard fa-fw"})

答案 3 :(得分:0)

       @Html.ActionLink("AppStore", "Index", "Home", new {ProductID = 73}, new {@class="fa fa-dashboard fa-fw"})

您已经询问了一个关于选择哪个重载的问题。当您启动paranthesis&#34;(&#34;在@ HTML.ActionLink之后,您可以使用向上和向下箭头滚动查看哪个重载最适合您。如果您想指定productID等,可以使用上面的代码。