我可以在MVC3类添加到HTML.ActionLink [英] Can I add a class to an HTML.ActionLink in MVC3
本文介绍了我可以在MVC3类添加到HTML.ActionLink的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的code和想添加一个类的链接。是否有可能做到这一点在MVC3?
Html.ActionLink(新建,创建)
解决方案
是的,你可以添加具有对象重新presenting CSS类另一个参数:
Html.ActionLink(新建,创建,CONTROLLERNAME,空,新的{@类=yourCSSclass})
它可以被翻译成:
Html.ActionLink(链接文本,操作名称,控制器名称,路由值对象,HTML属性的对象)
编辑:
若要添加自定义样式,使用:
Html.ActionLink(
创建新的,
创建,
CONTROLLERNAME,
空值,
新{@类=yourCSSclass,@风格=宽度:100像素;颜色:红色; }
)
I have this code and would like to add a class to the link. Is it possible to do this in MVC3?
Html.ActionLink("Create New", "Create")
解决方案
Yes, you can just add another parameter with object representing css class:
Html.ActionLink("Create New", "Create", CONTROLLERNAME, null, new { @class= "yourCSSclass"} )
It can be translated to:
Html.ActionLink(link text, action name, controller name, route values object, html attributes object)
Edit:
To add custom styles, use this:
Html.ActionLink(
"Create New",
"Create",
CONTROLLERNAME,
null,
new { @class= "yourCSSclass", @style= "width:100px; color: red;" }
)
这篇关于我可以在MVC3类添加到HTML.ActionLink的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文