基于动态Action的URL菜单问题c# mvc
我在 PartialView 中实现基于动态操作的菜单系统时遇到问题,如下所示:
<ul class="tabs">
<li <% if (ViewContext.RouteData.Values["Action"] == "Index"){ %>class="active"<% } %>><a href="/talent">Home</a></li>
<li <% if (ViewContext.RouteData.Values["Action"] == "account"){ %>class="active"<% } %>><a href="/talent/account">Account settings</a></li>
<li <% if (ViewContext.RouteData.Values["Action"] == "password"){ %>class="active"<% } %>><a href="/talent/password">Password settings</a></li>
<li <% if (ViewContext.RouteData.Values["Action"] == "profile"){ %>class="active"<% } %>><a href="/talent/profile">Edit profile</a></li>
<li <% if (ViewContext.RouteData.Values["Action"] == "messages"){ %>class="active"<% } %>><a href="/talent/messages">Messages</a></li>
<li id="logout"><a href="/logout">Logout</a></li>
</ul>
问题是只有“索引”菜单项有效,其中 CSS 类在 HTML 标记中呈现。其他人没有,真的很奇怪。有什么想法吗?
i'm having issues implenting a dynamic action-based menu system in a PartialView as below:
<ul class="tabs">
<li <% if (ViewContext.RouteData.Values["Action"] == "Index"){ %>class="active"<% } %>><a href="/talent">Home</a></li>
<li <% if (ViewContext.RouteData.Values["Action"] == "account"){ %>class="active"<% } %>><a href="/talent/account">Account settings</a></li>
<li <% if (ViewContext.RouteData.Values["Action"] == "password"){ %>class="active"<% } %>><a href="/talent/password">Password settings</a></li>
<li <% if (ViewContext.RouteData.Values["Action"] == "profile"){ %>class="active"<% } %>><a href="/talent/profile">Edit profile</a></li>
<li <% if (ViewContext.RouteData.Values["Action"] == "messages"){ %>class="active"<% } %>><a href="/talent/messages">Messages</a></li>
<li id="logout"><a href="/logout">Logout</a></li>
</ul>
The problem is that only the 'Index' menu item works, where the CSS class is rendered in the HTML markup. The others don't, really strange. Any ideas??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除 Index 之外的所有操作方法均以小写字母指定。使用不区分大小写的比较而不是“==”
All action methods other than Index specified with lowcase. Use case insensitive comparison instead of "=="