我是MVC新手,遇到了问题。我有一个HTML页面,当从导航栏中单击该部分的名称时,该页面向下滚动到一个部分,但现在我必须将此HTML代码行更改为MVC:
<li><a class="page-scroll" href="#services">Services</a></li>
我曾尝试使用Html.ActionLink但尚未取得任何成功!
到目前为止我所拥有的:
@Html.ActionLink("Services", "Index", "Home", new { area = "#services" }, new { @class = "page-scroll" })
答案 0 :(得分:1)
创建自己的帮助器或使用原始html
<li><a href="@Url.Action("Action", "Controller")#services">Link Text</a></li>
OR
<%= Html.ActionLink("Link Text", "Action", "Controller", null, null, "services", new { parameter = "example"}, null) %>
在索引页面上:
<div id="services">
<p>Here is the content you want to make show when you click the link</p>
</div>
当您点击“链接文字”时,它会引导您进入“索引”页面的“服务”部分。
答案 1 :(得分:-1)
尝试
@Html.ActionLink("Services", "Index", "Home#services", new { @class = "page-scroll" })