views:

708

answers:

1

In an ASP.NET MVC view I'd like to include a link of the form: <a href="blah">Link text <span>with further descriptive text</span></a>

Trying to include the element in the linkText field of a call to Html.ActionLink ends up with it being encoded (as would be expected). Are there any recommended ways of achieving this?

+7  A: 

You could use Url.Action to build the link for you:

<a href="<% =Url.Action("Action", "Controller")%>">link text <span>with further blablah</span></a>

or use Html.BuildUrlFromExpression:

<a href="<% =Html.BuildUrlFromExpression<Controller>(c => c.Action()) %>">text <span>text</span></a>
Casper
Should be noted that `Html.BuildUrlFromExpression` is currently in the MVC Futures assembly and therefore not available in a standard install of the Beta.
Giraffe