Asp.net mvc 2 追加'#部门id';使用htmlhelper按id引用html元素
我如何附加到这样的urlAsp.net mvc 2 追加'#部门id';使用htmlhelper按id引用html元素,asp.net-mvc-2,html-helper,html.actionlink,Asp.net Mvc 2,Html Helper,Html.actionlink,我如何附加到这样的url mysite.com/articles/1/my-first-article 具有div id#commentList的元素 mysite.com/articles/1/my-first-article#commentList <%: Html.ActionLink("text", "action", new {/* ??? HOW TO SET IT HERE ??? */})%> mysite.com/articles/1/my first ar
mysite.com/articles/1/my-first-article
具有div id#commentList的元素
mysite.com/articles/1/my-first-article#commentList
<%: Html.ActionLink("text", "action", new {/* ??? HOW TO SET IT HERE ??? */})%>
mysite.com/articles/1/my first article#commentList
尝试使用(获取片段的url),这将允许您生成包含片段部分的所需url:
<%= 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
) %>