SamJolly
SamJolly

Reputation: 6477

Trying to convert this Html.Action Code to Html.ActionLink

I am using MVC3, ASP.NET4.5 and Razor.

I have some Html.Action Code, and would ideally like to convert it to Html.ActionLink as I am thinking of using a security extension function that has been written for ActionLinks.

My code is:

<a href="@Url.Action("Edit", "Order", new { id=item.Id}, null)"><span class="fa fa-pencil ss-prime ss-cmd" title="Edit Order"></span></a> 

Can this be implemented using an ActionLink?

The "fa fa-pencil" code is a webfont, and I need this.

Thanks in advance

Upvotes: 0

Views: 250

Answers (1)

blorkfish
blorkfish

Reputation: 22844

If you use an action link, you may need to modify your styles slightly:

Html.ActionLink("edit order", "Edit", "Order"
   , new { id= 1 }
   , new { @class="fa fa-pencil" }) // <-- html attributes

This will create an a href, but attach the css styles to the a tag, not the span.

<a class="fa fa-pencil" href="/Order/Edit/1">edit order</a>

Upvotes: 1

Related Questions