Enable current view menu highlight (V2.0, )

Source: Internet
Author: User

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:


 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.