3

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

Rahul Nikate
  • 6,192
  • 5
  • 42
  • 54
thenna
  • 423
  • 1
  • 5
  • 26

3 Answers3

3

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" })
Rahul Nikate
  • 6,192
  • 5
  • 42
  • 54
  • You don´t need to add two different instances, you can do @Html.ActionLink("Edit", "Edit", new { id = item.ClientId, @class = "fa fa-edit" } – Gerry Jul 14 '16 at 23:38
2

You can do this:

@Html.ActionLink("Edit", "Edit", new { id=item.ClientId }, new { @class = "myCssClass" })

The @ is important because class is a C# keyword.

Hope it helps!

Itay Podhajcer
  • 2,616
  • 2
  • 9
  • 14
2

You can set it via htmlAttributes parameter of ActionLink MVC helper method like below, you should use @class property for your htmlAttributes object.

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

Hope this helps

Cihan Uygun
  • 2,128
  • 1
  • 16
  • 26