I have the following:
@Html.ActionLink("Register", "Register", "Users")
I would like to make the link include the following:
title="Register your ID"
rel="nofollow"
Is there a way that I can do this with MVC3?
I have the following:
@Html.ActionLink("Register", "Register", "Users")
I would like to make the link include the following:
title="Register your ID"
rel="nofollow"
Is there a way that I can do this with MVC3?
Simply use the proper overload of the ActionLink
method:
@Html.ActionLink(
"Register", // linkText
"Register", // actionName
"Users", // controllerName
null, // routeValues
new { // htmlAttributes
title = "Register your ID",
rel = "nofollow"
}
)
Should generate (assuming default routes setup):
<a href="/Users/Register" rel="nofollow" title="Register your ID">Register</a>
@Html.ActionLink("Register", "Register", "Users", null,
new {title = "Register your ID", rel="nofollow")
The framework will parse that object and place the items as attributes in the rendered anchor.