Handling Movie Navigation

Setting Navigation Item Title and Icon

When Sergen generated code for Movie table, it also created a navigation item entry. In Serene, navigation items are created with special assembly attributes.

Open MoviePage.cs in the same folder, on top of it you’ll find this line:

  1. [assembly:Serenity.Navigation.NavigationLink(int.MaxValue, "MovieDB/Movie",
  2. typeof(MovieTutorial.MovieDB.Pages.MovieController))]
  3. namespace MovieTutorial.MovieDB.Pages
  4. {
  5. //...

First argument to this attribute is display order for this navigation item. As we only have one navigation item in Movie category yet, we don’t have to mess with ordering yet.

Second parameter is navigation title in “Section Title/Link Title” format. Section and navigation items are seperated with a slash (/).

Lets change it to Movie Database/Movies.

  1. [assembly:Serenity.Navigation.NavigationLink(int.MaxValue, "Movie Database/Movies",
  2. typeof(MovieTutorial.MovieDB.Pages.MovieController), icon: "icon-camrecorder")]
  3. namespace MovieTutorial.MovieDB.Pages
  4. {
  5. //..

Navigation Item Title and Icon

We also changed navigation item icon to icon-camcorder. Serene template has two sets of font icons, Simple Line Icons and Font Awesome. Here we used a glyph from simple line icons set.

To see list of simple line icons and their css classes, visit link below:

http://thesabbir.github.io/simple-line-icons/

FontAwesome is available here:

https://fortawesome.github.io/Font-Awesome/icons/

There is also a page in Serene under Theme Samples / UI Elements / Icons containing a list of these icon sets.

Ordering Navigation Sections

As our Movie Database section is auto generated last, it is displayed at the bottom of navigation menu.

We’ll move it before Northwind menu.

As we saw recently, Sergen created a navigation item in MoviePage.cs. If navigation items are scattered through pages like this, it would be hard to see the big picture (list of all navigation items) and order them easily.

So we move it to our central location which is at MovieTutorial.Web/Modules/Common/Navigation/NavigationItems.cs.

Just cut the below lines from MoviePage.cs:

  1. [assembly:Serenity.Navigation.NavigationLink(int.MaxValue, "Movie Database/Movies",
  2. typeof(MovieTutorial.MovieDB.Pages.MovieController), icon: "icon-camrecorder")]

Move it into NavigationItems.cs and modify it like this:

  1. using Serenity.Navigation;
  2. using Northwind = MovieTutorial.Northwind.Pages;
  3. using Administration = MovieTutorial.Administration.Pages;
  4. using MovieDB = MovieTutorial.MovieDB.Pages;
  5. [assembly: NavigationLink(1000, "Dashboard", url: "~/", permission: "",
  6. icon: "icon-speedometer")]
  7. [assembly: NavigationMenu(2000, "Movie Database", icon: "icon-film")]
  8. [assembly: NavigationLink(2100, "Movie Database/Movies",
  9. typeof(MovieDB.MovieController), icon: "icon-camrecorder")]
  10. [assembly: NavigationMenu(8000, "Northwind", icon: "icon-anchor")]
  11. [assembly: NavigationLink(8200, "Northwind/Customers",
  12. typeof(Northwind.CustomerController), icon: "icon-wallet")]
  13. [assembly: NavigationLink(8300, "Northwind/Products",
  14. typeof(Northwind.ProductController), icon: "icon-present")]
  15. // ...

Here we also declared a navigation menu (Movie Database) with film icon. When you don’t have an explicitly defined navigation menu, Serenity implicitly creates one, but in this case you can’t order menu yourself, or set menu icon.

We assigned it a display order of 2000 so this menu will display just after Dashboard link (1000) but before Northwind menu (8000).

We assigned our Movies link a display order value of 2100 but it doesn’t matter right now, as we have only one navigation item under Movie Database menu yet.

First level links and navigation menus are sorted according to their display order first, then second level links among their siblings.

Here is how it looks like after these changes:

Movie Database Moved

Troubleshooting Some Issues with Visual Studio

In case you didn’t notice already, Visual Studio doesn’t let you modify code while your site is running. Also your site stops when you stop debugging, so you can’t keep browser window open and refresh after rebuilding.

To solve this issue, we need to disable Edit And Continue (have no idea why).

Right Click MovieTutorial.Web project, click Properties, in the Web tab, uncheck Enable Edit And Continue under Debuggers.

Unfortunately, the solution above stops works in Visual Studio 2015 Update 2. Only workaround so far seems like starting without debugging, e.g. Ctrl+F5 instead of F5.

Solution above only applies to ASP.NET MVC version, not ASP.NET CORE version.

Also, on your site, top blue progress bar (which is a Pace.js animation), keeps running all the time like it is still loading something. It is thanks to the Browser Link feature of Visual Studio. To disable it, locate its button in Visual Studio toolbar that looks like a refresh button (next to play icon with browser name like Chrome), click dropdown and uncheck Enable Browser Link.

It’s also possible to disable it with a web.config setting

  1. <appsettings>
  2. <add key="vs:EnableBrowserLink" value="false" />
  3. </appsettings>

Serene 1.5.4 and later has this in web.config by default, so you might not experience this issue

I’m not sure if there is a corresponding setting in appsettings.json file of ASP.NET Core version