开发者

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>


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


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜