I'm trying to set the style of an action link like so:
<text><p>Signed in as @Html.ActionLink(Context.User.Identity.Name,"Index",new { Controller="Account", @style="text-transform:capitalize;" })</p>
I'd expect this to be rendered as
<p>Signed in as <a href="Index" style="text-transform:capitalize;">MyName</a></p>
However, what's generated is
<p>Signed in as <a href="/Account?style=text-transform%3Acapitalize%3B">MyName</a></p>
with the style appended to the url instead. What am I doing wrong?
This question is related to
css
asp.net-mvc-3
razor
Reviving an old question because it seems to appear at the top of search results.
I wanted to retain transition effects while still being able to style the actionlink so I came up with this solution.
<div class="parent-style-one"> @Html.ActionLink("Homepage", "Home", "Home") </div>
.parent-style-one { /* your styles here */ }
.parent-style-one a { text-decoration: none; }
.parent-style-one a:hover { text-decoration: underline; -webkit-transition-duration: 1.1s; /* Safari */ transition-duration: 1.1s; }
This way I only target the child elements of the div in this case the action link and still be able to apply transition effects.
VB sample:
@Html.ActionLink("Home", "Index", Nothing, New With {.style = "font-weight:bold;", .class = "someClass"})
Sample Css:
.someClass
{
color: Green !important;
}
In my case, I found that I need the !important attribute to over ride the site.css a:link css class
Source: Stackoverflow.com