【问题标题】:append '#div-id' to reference a html element by id using htmlhelper使用 htmlhelper 附加 '#div-id' 以通过 id 引用 html 元素
【发布时间】:2011-06-19 21:58:39
【问题描述】:

我如何附加到这样的网址

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 ??? */})%>

【问题讨论】:

    标签: asp.net-mvc-2 html-helper html.actionlink


    【解决方案1】:

    尝试使用proper overload(带片段的那个),它可以让您生成包含片段部分的所需网址:

    <%= 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
    ) %>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-18
      • 2015-05-28
      • 1970-01-01
      • 2014-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-04
      相关资源
      最近更新 更多