0

How do i append to an url like this

mysite.com/articles/1/my-first-article

the element with the div id #commentList

mysite.com/articles/1/my-first-article#commentList


<%: Html.ActionLink("text", "action", new {/* ??? HOW TO SET IT HERE ??? */})%>
aGuy
  • 217
  • 1
  • 3
  • 8

1 Answers1

2

Try using the proper overload (the one that takes a fragment) which will allow you to generate the desired url containing a fragment portion:

<%= Html.ActionLink(
    "some text",     // linkText
    "articles",      // actionName
    null,            // controllerName
    null,            // protocol
    null,            // hostName
    "commentList",   // fragment <-- that's what you need
    new { id = 1 },  // routeValues
    null             // htmlAttributes
) %>
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928