From 59e5f471db60adbf77e4f52bc4ecfff1d3533cf2 Mon Sep 17 00:00:00 2001 From: Jason Zhu Date: Wed, 8 Sep 2021 23:41:08 +1000 Subject: [PATCH] 8.1.3.4 Highlighting the Current Category; Listing 8-10. Highlighting the Selected Category in the Menu.cshtml File --- .../SportsStore.WebUI/Views/Nav/Menu.cshtml | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/SportsStore/SportsStore.WebUI/Views/Nav/Menu.cshtml b/SportsStore/SportsStore.WebUI/Views/Nav/Menu.cshtml index f2f05d8..43cf756 100644 --- a/SportsStore/SportsStore.WebUI/Views/Nav/Menu.cshtml +++ b/SportsStore/SportsStore.WebUI/Views/Nav/Menu.cshtml @@ -6,14 +6,16 @@ @foreach (var link in Model) { - @Html.RouteLink(link, new - { - controller = "Product", - action = "List", - category = link, - page = 1 - }, new - { - @class = "btn btn-block btn-default btn-lg" - }) + @Html.RouteLink(link, + new + { + controller = "Product", + action = "List", + category = link, + page = 1 + }, + new + { + @class = "btn btn-block btn-default btn-lg" + (link == ViewBag.SelectedCategory ? " btn-primary" : "") + }) }