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

3
  • what are you trying to achieve? <a><span></span></a>? I dont think that valid html or xhtml! Commented Jul 31, 2010 at 18:22
  • Ok - so I was smoking my socks with my initial comment, see stackoverflow.com/questions/3379392/… Commented Jul 31, 2010 at 19:02
  • I'm using iWebkit (iwebkit.net) to create native-looking websites for the iPhone. I'm desinging a Mafia-Wars style RPG ;-) Commented Jul 31, 2010 at 19:25

2 Answers 2

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>
Sign up to request clarification or add additional context in comments.

2 Comments

How should I do that? I know how to make an <a> tag, but which must be the href parameter? I'm quite new to all this MVC-stuff ;)
Thank you! This helped me out, since I want to deploy on IIS 6, and from the things I read, I need to change some settings, which will render hardcoded paths in the href parameter invalid.
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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.