在视图中获取操作名称 (ASP.NET MVC2)
我想获取母版页中的当前操作名称,以便我可以找到“当前”页面链接并将其标记为“当前”。
这是我在母版页中查看的代码片段:
<ul>
<li>
<a href="<%= Url.Action("Index", "Admin")%>" class="main current">Index</a>
</li>
<li>
<a href="<%= Url.Action("Show", "Admin")%>" class="main">Show</a>
</li>
<li>
<a href="<%= Url.Action("Delete", "Admin")%>" class="main">Delete</a>
</li>
</ul>
如您所见,索引超链接有一个“current”类,这使得它通过 css 文件突出显示。
我想检查用户正在访问的操作,并将超链接设置为“当前”。我在网上搜索过,想知道最好的解决方案是什么?
另外,如果你们对完成这项任务有任何其他建议,我也很感激。
提前致谢, Sadullah
PS:尽管我找到了解决方案,但一定有更好的方法来做到这一点。
I want to get current action name in master page, so that i can find the "current" page link and mark it as "current".
Here is my view code snippet from Master Page:
<ul>
<li>
<a href="<%= Url.Action("Index", "Admin")%>" class="main current">Index</a>
</li>
<li>
<a href="<%= Url.Action("Show", "Admin")%>" class="main">Show</a>
</li>
<li>
<a href="<%= Url.Action("Delete", "Admin")%>" class="main">Delete</a>
</li>
</ul>
As you can see, the Index hyperlink has a class of "current", which makes it highlighted via css files.
I want to check the Action that user is visiting, and make the hyperlink "current" with respect to that. I have searched through web, and wondering what is the best solution to that?
Also, I appreciate if you guys have any other suggestions about accomplishing this task.
Thanks in advance,
Sadullah
PS: Even though I found the solution, there must be a nicer way to do this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论