In ASP.NET MVC3 This is a regular actionlink at Razor view :
<li>@Html.ActionLink("Home", "Index", "Home")</li>
and related html dom is:
<li><a href="/HomePage/">Home</a></li>
So my css work correctly if I add css class to the <a>
element like the following:
<li><a class="MyCssClass" href="/HomePage/">Home</a></li>
Does any one know how can I do this?
You can do this to pass in html attributes.
@Html.ActionLink("Home", "Index", "Home", new { @class = "MyCssClass" })
You can pass other html attributes as well.
@Html.ActionLink("Home", "Index", "Home", new { @class = "MyCssClass", otherAttributeName = 1 })
hope this helps
<li>@Html.ActionLink("Home", "Index", "Home", new { @class = "myclass" })</li>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With