开发者

Html.ActionLink and HTML as parameter (ASP.Net MVC 2)

Html.ActionLink("<span class=\"title\">Retry</span><span class=\"arrow\"></span>", "Login", "U开发者_Go百科ser")

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


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>


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)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜