ADC
ADC

Reputation: 617

ActionLink MVC4 Razor with icon class

I have this code HTML:

<a class="tooltip-tip2 ajax-load" href="...."><i class="entypo-menu"></i><span>Page Example</span></a>

And I would use this:

@Html.ActionLink("Crea mensilizzazione " + s.nome, "CheckCredentials", "giornaliero", new { @class= "tooltip-tip2 ajax-load" , id=s.id, isScuole = false},null)

How can add the <i class="entypo-menu"></i> in this @HTML.ActionLink???

Upvotes: 0

Views: 538

Answers (1)

David
David

Reputation: 218950

I don't think the ActionLink helper can accomplish this. but you can use @Url.Action() in custom markup to accomplish the same thing:

<a class="tooltip-tip2 ajax-load" href="@Url.Action("CheckCredentials", "giornaliero")"><i class="entypo-menu"></i><span>Page Example</span></a>

Url.Action basically just creates the URL for the link, not any of the markup related to building the link itself. So it can be used in all sorts of custom client-side code. (For example, another common use is to embed it in some JavaScript code to define an AJAX service URL.)

Edit: You can add route values exactly the same way as you do with @Html.ActionLink:

@Url.Action("CheckCredentials", "giornaliero", new { id = s.id, isScuole = false })

Upvotes: 2

Related Questions