@Html.ActionLink link text containing HTML [duplicate]
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.
精彩评论