您的位置:首页 > 编程语言 > ASP

ASP.NET MVC: how to include <span> in link from Html.ActionLink?

2011-07-05 20:17 751 查看
ASK:

I need the text of a link wrapped with
<span>
as in:

<a href="/foo.html"><span>Edit Group</span></a>

Can I do that with Html.ActionLink? This doesn't work:

<%=Html.ActionLink("<span>Edit Group</span>", "Edit", New With {.id = "bar"})%>

It just HTML encodes the
<
and
>
as
<
and
>
.

Is there a simple solution, or should I build the links by hand with
Url.Action?

This is for use with jQuery-UI Tabs. Tab labels need
to be wrapped in
<span>
to get animation when AJAX content is
loading.

Answer:

You can use the Url.Action helper method as a workaround (in case no other
answers better fit your needs).

For example, the following can be in marked up in your view:

<a href="<%= Url.Action("Edit",
New With {.id = "bar"}) %>">
<span>Edit Group</span>
</a>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: