代码 : @Html.ActionLink("Link", "Action", "Controller", new { id = Id } )
目前我可以生成这样的链接:
我想生成一个这样的链接:
但我无法编辑路线/创建另一条路线.
什么是最好的解决方案?
我在网上搜索了一个答案,并尝试了Brad Wilson建议的解决方案: 在ASP.NET MVC中包含一个锚标记Html.ActionLink
但是,这对我不起作用.
这是我做的:
在Controller/Details/_PartialView文件中,我放置了一个锚标记:
<a name="anchor-point"></a>
Run Code Online (Sandbox Code Playgroud)
呈现Controller/Details时,显然会呈现_PartialView文件.
在Controller/Index中,我有一个ActionLink,如下所示
<td>@Html.ActionLink("linkText", "Details", "Controller", null, null, "anchor-point", new { item => item.ID }, null)</td>
Run Code Online (Sandbox Code Playgroud)
当我在Chrome中检查呈现的HTML时,上面的链接不是我想要的,这是:
../Controller/Details/id#anchor-point
Run Code Online (Sandbox Code Playgroud)
自原帖以来,我是否误解了某些内容或更改了用法.我正在使用MVC 5 ASP.NET 4.5.
关心克雷格
我是 ASP.NET 的新手,我想弄清楚如何创建具有下拉功能的导航栏菜单项。我特别使用这个主题。在他们的示例代码中,他们演示了下拉功能,但在我的默认 MVC 应用程序中,我使用 _Layout.cshtml 创建我的导航栏。我很难找出正确的语法。
我已经section
在我的 Index.cshtml 页面中实现了s,我希望第一个导航栏菜单项下拉菜单相应地转到。我怎样才能做到这一点?
索引.cshtml
<section id="item 1">...</section>
<section id="item 2">...</section>
<section id="item 3">...</section>
Run Code Online (Sandbox Code Playgroud)
_Layout.cshtml
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
@Html.ActionLink("My Application", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
@*<li>@Html.ActionLink("Index", "Index", "Home")</li>*@
<li class="dropdown">
<a class="dropdown-toggle" role="button" aria-expanded="false" data-toggled="dropdown">@Html.ActionLink("Home", "Index", "Home")</a> …
Run Code Online (Sandbox Code Playgroud)