Reputation: 5075
i am trying to print icon in actionLink in Razor code but it is not happening... I am using actionLink with action-Name and controller with the class and use this class in css to print icon.... i don't know where i am doing mistake ???
I am getting following line in page source;
<a class="CreateNewEntry_Icon" href="/Qualification/CreateNewFreeZone?Length=13">New FreeZone</a>
public ActionResult CreateNewFreeZone()
{
return PartialView("Partial_CreateNewFreeZone");
}
@Html.ActionLink("New FreeZone", "CreateNewFreeZone", "Qualification", new { @class = "CreateNewEntry_Icon" })
CSS:
.CreateNewEntry_Icon {
width:24px;
height:24px;
background:url("~/ImagesAndIcons/Icons/Add_New.png") no-repeat;
}
Upvotes: 2
Views: 3630
Reputation: 33306
You need this instead:
@Html.ActionLink("New FreeZone", "CreateNewFreeZone", "Qualification", null, new { @class = "CreateNewEntry_Icon" })
Your original is passing the class to the routeValues instead of the htmlAttributes parameter.
Adding the extra parameter, null in this case results in the correct overload being called which takes the htmlAttributes as the last parameter.
Upvotes: 2
Reputation: 6398
Try this
@Html.ActionLink("New FreeZone", "CreateNewFreeZone", "Qualification", new{ }, new { @class = "CreateNewEntry_Icon" })
Upvotes: 1