alex.b
alex.b

Reputation: 4567

ASP.NET MVC: generating action link with custom html in it


How can I generate action link with custom html inside.
Like following:
<a href="http://blah-blah/.....">
<span class="icon"/> New customer
</a>

Upvotes: 8

Views: 5688

Answers (2)

Ian Mbae
Ian Mbae

Reputation: 146

For newer versions of .net,

replace

 href="<% =Url.Action("Create","Customers") %>"

with

href="@Url.Action("Create","Customers")"

to give something like

<a href="@Url.Action("Create","Customers")">
   <span class="icon"/> New customer 
</a>

Upvotes: 0

mathieu
mathieu

Reputation: 31202

You can use the UrlHelper class :

<a href="<% =Url.Action("Create","Customers") %>">
    <span class="icon"/> New customer
</a>

The MSDN link is here : http://msdn.microsoft.com/en-us/library/system.web.mvc.urlhelper.aspx

Upvotes: 9

Related Questions