创建了链接文本的HTML元素的ActionLink的 [英] Create an ActionLink with HTML elements in the link text

查看:123
本文介绍了创建了链接文本的HTML元素的ActionLink的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个ASP.NET MVC视图,我想包括以下形式的链接:

In an ASP.NET MVC view I'd like to include a link of the form:

<a href="blah">Link text <span>with further descriptive text</span></a>

试图包括&LT;跨度&GT; 元素在通话的 LINKTEXT 字段设置为 Html.ActionLink()与它是连接codeD(正如所预料的)结束。

Trying to include the <span> element in the linkText field of a call to Html.ActionLink() ends up with it being encoded (as would be expected).

是否有实现这一目标的任何推荐的方式?

Are there any recommended ways of achieving this?

推荐答案

您可以使用Url.Action建立链接给你:

You could use Url.Action to build the link for you:

<a href="<% =Url.Action("Action", "Controller")%>">link text <span>with further blablah</span></a>

或使用Html.BuildUrlFromEx pression:

or use Html.BuildUrlFromExpression:

<a href="<% =Html.BuildUrlFromExpression<Controller>(c => c.Action()) %>">text <span>text</span></a>

这篇关于创建了链接文本的HTML元素的ActionLink的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆