ASP. net mvc Bootstrap template selects the menu to highlight the current method, mvcbootstrap

Source: Internet
Author: User

ASP. net mvc Bootstrap template selects the menu to highlight the current method, mvcbootstrap

When the current page is displayed in the background and the menu item of the current page is highlighted, we can use the js method or program implementation, and use the Bootstrap template to process highlight and expand one of the methods.

1. import data in the project

<script src="/assets/admin/layout/scripts/layout.js"></script>

 

2. Add a unique ID for the sub-project, and click the current page to send the current unique ID to the Controller.

                                <a href="@item2.LinkUrl?id=@item2.Id" id="@item2.Id">                                    <i class="icon-settings"></i> @item2.Name                                    @if (list.Where(d => d.ParentId == item2.Id).Count() > 0)                                    {<span class="arrow "></span>}                                </a>

3. input the highlighted item id in the Controller that needs to be highlighted on the home page.

public ActionResult List(string id){    ViewBag.CLASSID = id.ToLower();    return View();}

4. Set JS highlighting on the page

@section footer{    <script>        jQuery(document).ready(function () {            Layout.setSidebarMenuActiveLink('set', $('#@ViewBag.CLASSID'));        });    </script>}

5. Allow the project. Click the current program to automatically add the expanded and highlighted style.

 

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.