开发者

@Html.ActionLink link text containing HTML [duplicate]

This question already has an answer here: Closed 11 years ago.

Possible Duplicate:

Razor syntax prevent escaping html in an action link

Hi all,

Must be an easy way to do this but have tried and failed thus far...

Have a @Html.ActionLink and within the link text I'd like to render a span. Currently doing so encodes the element and it's rendered as text on the page.

Here's what I'm trying:

@Html.ActionLink("Here's some text 开发者_如何学Go<span class='myClass'>inside the span</span>"), "ActionName", "ControllerName")

Any ideas how I get the link text to handle HTML and render it correctly?

Thanks Tim


The ActionLink method can only take plain text.

You should write your own <a> tag and use @Url.Action(...).


The ActionLink method always HTML-encodes the link text parameter. You would have to write your own version of the helper that does not perform such encoding.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜