我有以下内容:
@Html.ActionLink("Register", "Register", "Users")
我想将链接包含以下内容:
title="Register your ID"
rel="nofollow"
有没有办法可以用MVC3做到这一点?
答案 0 :(得分:4)
只需使用ActionLink
方法的正确重载:
@Html.ActionLink(
"Register", // linkText
"Register", // actionName
"Users", // controllerName
null, // routeValues
new { // htmlAttributes
title = "Register your ID",
rel = "nofollow"
}
)
应该生成(假设默认路由设置):
<a href="/Users/Register" rel="nofollow" title="Register your ID">Register</a>
答案 1 :(得分:0)
@Html.ActionLink("Register", "Register", "Users", null,
new {title = "Register your ID", rel="nofollow")
框架将解析该对象并将项目作为属性放置在渲染锚点中。