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
Can I do that with Html.ActionLink? This doesn't work:
It just HTML encodes the
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
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:
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>
相关文章推荐
- how to get all controller attribute action and parameter in asp.net mvc
- How to create custom html helper in Asp.net MVC 3 or 4
- How to use HTML-5 data-* attributes in ASP.NET MVC
- New <%: %> Syntax for HTML Encoding Output in ASP.NET 4 (and ASP.NET MVC 2)
- How to get the Current Controller Name, Action, or ID in ASP.NET MVC
- ASP.NET MVC 将IList<T>导出Excel文档的泛型类(继承自ActionResult)
- asp.net MVC 之 Html.ActionLink
- ASP.NET MVC 拓展ActionResult实现Html To Pdf 导出
- <转>ASP.NET MVC HtmlHelper用法大全
- ASP.NET MVC 混搭 ASP.NET WebForms 所导致的 Html.ActionLink/BeginForm 问题
- How to get all Errors from ASP.Net MVC modelState?
- How to Choose the Best Way to Pass Multiple Models in ASP.NET MVC
- 转载 ASP.NET MVC学习之(5):Html.ActionLink
- asp.net mvc_html.ActionLink的几种参数格式
- asp.net mvc <tr>变&lt;tr/&gt; @Html.Raw 作用
- How to bootstrap two angular apps in one asp.net mvc application
- ASP.NET 4(和ASP.NET MVC 2)中输出HTML编码的新语法<%:%>
- ASP.NET MVC Html.ActionLink使用说明
- How to achive the CRUD in ASP.NET MVC(VS2010)
- ASP.NET Razor C# Html.ActionLink to create empty link