It seems to be simple, but I can’t get anything to work. This code was generated by my template generator and needs to be changed.
<li><a href="../Home/Contact" class="active"><span class="l"></span><span class="r">
</span><span class="t">Nous contacter</span></a> </li>
My best bet up to now is:
<li><span class="l"></span><span class="r"></span>
@Html.RouteLink("Contact", new { Controller = "Home", Action = "Contact" }, new { @class = "t" })</li>
But it doesn’t do anything.
Just to make sur that my question is clear: The link works in both cases, that’s fine. The formating doesn’t work. That’s my issue here.
The second will generate:
which is different than what you had in the first place which might explain the formatting problems:
The problem with Html helpers such as Html.ActionLink and RouteLink is that they by always Html encode the text, so you cannot use HTML as text. So one possibility is the following:
Another possibility if you have lots of those to generate is to write a custom Html helper that will do the job for you:
and then: