2
Html.ActionLink("<span class=\"title\">Retry</span><span class=\"arrow\"></span>", "Login", "User")

Hi,

If I execute above code in ASP.Net MVC 2, I get the following output on my screen: Error? http://img27.imageshack.us/img27/2069/screenerror.png

How do I disable the escaping of the code, so my span is within the ActionLink, and not displayed as output?

I know this is expected behavior, to keep it safe, but I want it to interpret the HTML code I pass as a parameter.

Thanks! Yvan

friedkiwi
  • 2,158
  • 8
  • 29
  • 52
  • what are you trying to achieve? ? I dont think that valid html or xhtml! – Ahmad Jul 31 '10 at 18:22
  • Ok - so I was smoking my socks with my initial comment, see http://stackoverflow.com/questions/3379392/what-elements-can-be-contained-within-a-a-tag – Ahmad Jul 31 '10 at 19:02
  • I'm using iWebkit (http://www.iwebkit.net) to create native-looking websites for the iPhone. I'm desinging a Mafia-Wars style RPG ;-) – friedkiwi Jul 31 '10 at 19:25

2 Answers2

4

The ActionLink helper method can only be used for plain-text links.

You should manually make an <a> tag, like this:

<a href="<%=Url.Action("Login", "User") %>">
    <span class="title">Retry</span><span class="arrow"></span>
</a>
SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
0

I think the following also works.

<span class="title"><%= html.actionlink("Retry","Login", "User") %></span><span 
class="arrow"></span>

I mean, <.span>Retry<./span> is just <.span>plaintext<./span> which is the same as the actionlink text? ("." inserted for SO)

bastijn
  • 5,841
  • 5
  • 27
  • 43