在一个ASP.NET MVC视图中,我想包括一个形式的链接:
<a href="blah">Link text <span>with further descriptive text</span></a>
正在尝试将< span>在调用Html.ActionLink()的linkText字段中的元素最终会被编码(如预期的那样)。
有没有任何推荐的方法来实现这一点?
解决方法
您可以使用Url.Action为您建立连结:
<a href="<% =Url.Action("Action","Controller")%>">link text <span>with further blablah</span></a>
或使用Html.BuildUrlFromExpression:
<a href="<% =Html.BuildUrlFromExpression<Controller>(c => c.Action()) %>">text <span>text</span></a>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。