[英]How to implement tabs in a partial view in ASP MVC
我不知道從哪里開始在MVC項目中實現選項卡。 這是問題所在。 我想在局部視圖中實現選項卡,但我希望選項卡可用於我的所有控制器和視圖。 當我編寫選項卡時,我需要知道當前的控制器和視圖,以便我可以使用選項卡QueryString修改Html.ActionLink()。
我怎么能這樣做呢
<%= Html.ActionLink(QuestionSort.SortArray[0], "Current View", "Current Controller", null, new { rel = "nofollow" })%>
<% for (int x = 1; x < QuestionSort.SortArray.Length; x++)
{ %>
<%= Html.ActionLink(QuestionSort.SortArray[x], "Current View", "Current Controller", new { sort = Server.UrlEncode(QuestionSort.SortArray[x]) }, new { rel = "nofollow" })%>
<% } %>
您可以從ViewContext路由值獲取當前控制器。
我建議你這樣做是為了解決這個問題,你可能想要編寫一個HtmlHelper方法來生成一些HTML - 但是:
<%= this.ViewContext.RouteData.Values["controller"] %>
會打印出控制器名稱
和
<%= this.ViewContext.RouteData.Values["action"] %
那個行動
從這些數據構建一個上下文感知菜單應該很簡單
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.