Search code examples
c#asp.net-mvcrazorasp.net-mvc-5actionlink

How to add css class to Action link in MVC


I am creating MVC5 project.using Inspina theme I have using Entity framework its generated Code Like this Edit delete details

Following Like this

@Html.ActionLink("Edit", "Edit", new { id = item.ClientId })  |
@Html.ActionLink("Details", "Details", new { id = item.ClientId }) |
@Html.ActionLink("Delete", "Delete", new { id = item.ClientId })

Previous added custom font icon edit button and delete class like this

 <a class="fa fa-edit">@Html.ActionLink("Edit", "Edit", new { id=item.ClientId })</a>
 <a class="fa fa-times">@Url.Action("Delete", new { id=item.ClientId })</a>

Finally I want fa fa-edit this class inside to action link code Entity framework Generator. How can I add looks like my previous button


Solution

  • You can add class to ActionLink like this

    @Html.ActionLink("Edit", "Edit", new { id = item.ClientId }, new { @class = "fa fa-edit" }) 
    @Html.ActionLink("Delete", "Delete", new { id = item.ClientId }, new { @class = "fa fa-times" })