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 <span>
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?
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>