添加CSS类ASP.NET MVC ActionLink的的 [英] Add Css Class to ActionLink of ASP.NET MVC
本文介绍了添加CSS类ASP.NET MVC ActionLink的的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在ASP.NET MVC3这是在的Razor视图经常ActionLink的:
In ASP.NET MVC3 This is a regular actionlink at Razor view :
<li>@Html.ActionLink("Home", "Index", "Home")</li>
和相关HTML DOM是:
and related html dom is:
<li><a href="/HomePage/">Home</a></li>
所以,我的CSS工作,如果我正确添加CSS类的&LT; A&GT;
像下面的元素:
<li><a class="MyCssClass" href="/HomePage/">Home</a></li>
是否有任何人知道我能做到这一点?
Does any one know how can I do this?
推荐答案
您可以做到这一点的HTML属性传递。
You can do this to pass in html attributes.
@Html.ActionLink("Home", "Index", "Home", new { @class = "MyCssClass" })
您可以通过其它的HTML属性以及
You can pass other html attributes as well.
@Html.ActionLink("Home", "Index", "Home", new { @class = "MyCssClass", otherAttributeName = 1 })
希望这有助于
这篇关于添加CSS类ASP.NET MVC ActionLink的的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文