How can I generate action link with custom html inside.
Like following:
<a href="http://blah-blah/.....">
<span class="icon"/>
New customer
</a>
Asked
Active
Viewed 5,625 times
8

alex.b
- 4,547
- 1
- 31
- 52
2 Answers
9
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

mathieu
- 30,974
- 4
- 64
- 90
-
o, it is much obvious, that I thought :) Thanks! – alex.b Oct 07 '10 at 08:20
-
BTW, I've found some helpful info here: http://stephenwalther.com/blog/archive/2009/03/03/chapter-6-understanding-html-helpers.aspx and here http://iridescence.no/post/Rendering-Action-Links-in-ASPNET-MVC-Applications.aspx – alex.b Oct 07 '10 at 22:42
0
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>

Ian Mbae
- 138
- 1
- 2
- 13