Skip to content

Commit 5bd1051

Browse files
committed
Added PageNames class to make page names constant, and used in views to highlight active menu item.
1 parent 723281e commit 5bd1051

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

src/AbpCompanyName.AbpProjectName.Web/Startup/AbpProjectNameNavigationProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ public override void SetNavigation(INavigationProviderContext context)
1313
context.Manager.MainMenu
1414
.AddItem(
1515
new MenuItemDefinition(
16-
"Home",
16+
PageNames.Home,
1717
L("HomePage"),
1818
url: "",
1919
icon: "fa fa-home"
2020
)
2121
).AddItem(
2222
new MenuItemDefinition(
23-
"About",
23+
PageNames.About,
2424
L("About"),
2525
url: "Home/About",
2626
icon: "fa fa-info"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace AbpCompanyName.AbpProjectName.Web.Startup
2+
{
3+
public class PageNames
4+
{
5+
public const string Home = "Home";
6+
public const string About = "About";
7+
}
8+
}

src/AbpCompanyName.AbpProjectName.Web/Views/Home/About.cshtml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
<h2>@L("About")!</h2>
1+
@using AbpCompanyName.AbpProjectName.Web.Startup
2+
@{
3+
ViewBag.ActiveMenu = PageNames.About;
4+
}
5+
6+
<h2>@L("About")!</h2>
27

38
<div class="row">
49
<div class="col-lg-12">

src/AbpCompanyName.AbpProjectName.Web/Views/Home/Index.cshtml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
@section scripts
1+
@using AbpCompanyName.AbpProjectName.Web.Startup
2+
@{
3+
ViewBag.ActiveMenu = PageNames.Home;
4+
}
5+
6+
@section scripts
27
{
38
<environment names="Development">
49
<script src="~/js/views/home/index.js"></script>

0 commit comments

Comments
 (0)