Enable current view menu highlight (V2.0, )
Some time ago, Insus. NET shared a "Activate current view menu highlighting" http://www.cnblogs.com/insus/p/5287093.html, which is just a menu for the same controller.
Today I will share an article that presents a website menu orientation with different controllers. Find a Website: http://www.engtek.com/services.html, which has a menu orientation in addition to the Home Page:
The three tags will change accordingly as the Child pages are displayed. The tag #1 displays the menu text, tag #2, navigation menu, and tag #3 is the background image.
In general, when you design this website, you can put this code on each subpage to copy and modify text and background images.
<section class="main-contents dot-overlay engtek-bg8 parallax" data-stellar-background-ratio="0.6"> <div class="container"> <div class="section-title section-title-style7 padding-top30">
The highlighted section below is the changed section:
Or a better way, the view under each controller is made into a part of the view.
However, none of the above is what Insus. NET thinks. The practice of Insus. NET is to use a partial view on the entire site. If this is done, you need to know which controller and view the current request is.
It doesn't matter, this is known: Get current view name http://www.cnblogs.com/insus/p/5283729.html.
In fact, this is not a problem. The problem is that after you know the controller and view name, You have to obtain all views (I .e. sub menus) under the Controller Based on the Controller name ).
To solve this problem, Insus. NET uses interfaces, reflection, and other technologies:
The following is an interface. You can use the following attributes and methods based on your actual situation:
Then implement this interface in each controller or controller Entity:
Finally, some views can be written as follows: