8


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

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

2 Comments

o, it is much obvious, that I thought :) Thanks!
BTW, I've found some helpful info here: stephenwalther.com/blog/archive/2009/03/03/… and here iridescence.no/post/…
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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.