views:

1035

answers:

2

Whenever I use Html.ActionLink it always Html encodes my display string. For instance I want my link to look like this:

<a href="/posts/422/My-Post-Title-Here">More&hellip;</a>

it outputs like this: More&hellip;

&hellip is "..." incase you were wondering.

However the actionlink outputs the actual text "&hellip;" as the link text. I have the same problem with if I want to output this:

<a href="/posts/422/My-Post-Title-Here"><em>My-Post-Title-Here</em></a>

I wind up with: <em>My-Post-Title-Here</em>

Any idea how to do this?

+8  A: 

It looks like ActionLink always uses calls HttpUtility.Encode on the link text. You could UtlHelper to generate the href and build the anchor tag yourself.

<a href='<%= Url.Action( "Posts", ...) %>'>More&hellip;</a>
tvanfosson
YAHTZEE!!! That's exactly what I needed.
Micah
+4  A: 

Alternatively, just use a plain Unicode ellipsis character \u2026 and let MVC worry about how to encode it. Unless there's some particularly compelling reason you'd specifically need a hellip entity reference as opposed to a character reference or just including the character as simple UTF-8 bytes.

Alternative alternatively: just use three periods. The ellipsis (U+2026) is a compatibility character, only included to round-trip to pre-Unicode encodings. It gets you very little compared to simple dots.

bobince