Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Active Bootstrap Items Not Highlighted

Posted on 2013-06-26
2
Medium Priority
?
414 Views
Last Modified: 2013-08-22
Hi:

I've set up a Bootstrap Menu with the following code:

<div class="navbar navbar-inverse">
                <div class="navbar-inner">
                    <ul class="nav">
                        <li class="active"><a href="/Home/Index"><i class="icon-home icon-white"></i>Home</a></li>
                        <li>@Html.ActionLink("Home", "Index", "Home")</li>
                        @if (Request.IsAuthenticated)
                        {
                            <li>@Html.ActionLink("My Courses", "MyCourses", "Home")</li>
                        }
                        <li>@Html.ActionLink("FAQs", "Faqs", "Home")</li>
                    </ul>

                </div>
            </div>

Open in new window


What I'd like to do is that when a person presses on a selection other than home, that item is highlighted and home is not.

Any help in how to do this greatly appreciated.

RBS
0
Comment
Question by:RBS
2 Comments
 
LVL 11

Accepted Solution

by:
lenordiste earned 2000 total points
ID: 39279649
hi,

you just need to add the "active" class whenever you want the nav link to be the active one. The only trick is to figure out how to do this dynamically. You can do so in javascript or by using code behind. I thought this solution seemed decent to do just that :-)
http://chrisondotnet.com/2012/08/setting-active-link-twitter-bootstrap-navbar-aspnet-mvc/
0
 

Author Comment

by:RBS
ID: 39279970
Worked like a charm!

Thanks,
RBS
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Integration Management Part 2
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question