本文介绍了编辑Html.ActionLink输出字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用输出的Html.ActionLink以下HTML:

I'm trying to output the following HTML using Html.ActionLink:

<a href="/About" class="read-more">Read More<span class="arrow">→</span></a>

我得到它做一个ActionLink的,其输出&LT进行; A&GT; 标记,然后操纵字符串

<%= Html.ActionLink("[[replace]]", "Index", "About", null, new { @class = "read-more" }).ToHtmlString().Replace("[[replace]]", "Read More" + "<span class='arrow'>→</span>")%></p>

这将会是很好的,如果我可以把HTML直接进入ActionLink的,但似乎并没有要根据我的互联网搜索的方法。当然,它的工作原理,但它似乎是一个黑客。有没有更好的方式来做到这一点?

It'd be good if I could put HTML directly into the ActionLink but there doesn't seem to be a way based on my internet searches. Sure, it works but it seems like a hack. Is there a better way to accomplish this?

推荐答案

亚伦...你来解决这一问题?

Aaron...Did you work this out?

我用Url.Action href属性,当我需要的不仅仅是在输出HTML链接文本以外的东西。

I use Url.Action in the href attribute when I need something other than just the link text in the outputted HTML.

<a href="<%= Url.Action("About") %>" class="read-more">Read More<span class="arrow">→</span></a>

希望这有助于。

干杯,
-jc

Cheers,-jc

这篇关于编辑Html.ActionLink输出字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 11:28