ASP.net MVC 3 adding arbitrary text to the end of an ActionLink

Posted by infensus on Stack Overflow See other posts from Stack Overflow or by infensus
Published on 2011-02-14T23:05:55Z Indexed on 2011/02/14 23:25 UTC
Read the original article Hit count: 264

Filed under:
|
|

Hi I have a question about Html.ActionLink.

Imagine:

@Html.ActionLink(item.title, "Singlet", new { id = item.blog_id })

produces http://[url]/[controller]/Singlet/[id]

But what if I want to suffix some more arbitrary data at the end? For example:

http://[url]/[controller]/Singlet/[id]/#comments

To jump to the comments div. I know I can just make the string myself with something like:

@( new HtmlString(String.Format("<a href=\"Blog/Singlet/{0}/#comments\">link to comments</a>", item.blog_id)) )

But I am hoping there is a cleaner way, perhaps with ActionLink?

Thanks

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about asp.net-mvc-3