私はこれらを試しました:http: //developerstyle.posterous.com/highlighting-current-page-in-mvc-3-slick-tric
ASP.NETMVC-ナビゲーションでの現在のページの強調表示
ASP.netMVC-「現在の」リンクのナビゲーションと強調表示
上記のソリューションはいずれもRenderActionでは機能しません。
私はこれらを試しました:http: //developerstyle.posterous.com/highlighting-current-page-in-mvc-3-slick-tric
ASP.NETMVC-ナビゲーションでの現在のページの強調表示
ASP.netMVC-「現在の」リンクのナビゲーションと強調表示
上記のソリューションはいずれもRenderActionでは機能しません。
試すことができParentActionViewContext
ます。
機能していないのは何ですか?Html で「選択された」クラスを取得しませんか? それともあなたのcssが問題ですか?? あなたが提供したリンクはすべて実例のようです。
私はこれを試したことはありませんが、次のように現在の「ページ」を取得できるはずです。
String controller = String.Empty;
if (ViewContext.RouteData.Values.ContainsKey("controller")) {
controller = (String)ViewContext.RouteData.Values["controller"];
}
String action = String.Empty;
if (ViewContext.RouteData.Values.ContainsKey("action")) {
action = (String)ViewContext.RouteData.Values["action"];
}
String area = String.Empty;
if (ViewContext.RouteData.DataTokens.ContainsKey("area")) {
area = (String)ViewContext.RouteData.DataTokens["area"];
}
次に、これらの情報を大文字と小文字を区別して、作成したリンクと比較する必要があります。