Reputation: 9959
I would like to have the below html markup in MVC
<a href="/Home/ShoppingCart" class="view-cart">
<span data-hover="View Cart"><span>Cart</span></span></a>
but when i use this one
@Html.ActionLink("Cart", "ShoppingCart")
the result is
<a href="/Home/ShoppingCart">Cart</a>
So, how can i add that attributes and extra markups?
The problem is basically with the <spans>
involved, which i do not know how to render them within the hyperlink.
Upvotes: 0
Views: 1563
Reputation:
You cannot add additional html elements inside the <a>
element generated by @Html.ActionLink()
. You will need to use
<a href="@Url.Action("ShoppingCart")" class="view-cart">
<span data-hover="View Cart">
<span>Cart</span>
</span>
</a>
If its something you do regularly, you could consider creating you own HtmlHelper
extension method which generates the markup for you
Upvotes: 4