title: Highlighting Menu Bar in ASP.NET Web Application
body: <p>I built a web application using ASP.NET Visual Studio 2010 with Master Pages. As you will see that the project gives us a default menu bar item. I have 5 pages (links) listed on those menu bars. Now when a user goes to a specific page I want to highlight that menu bar link. I dont know how to do that :(</p>
  
  <p>I tried this on the Master Page Code Behind but it didnt work too:</p>
  
  <pre><code> foreach (MenuItem item in NavigationMenu.Items)
          {
              var navigateUrlParams = item.NavigateUrl.Split('/');
              if (Request.Url.AbsoluteUri.IndexOf(navigateUrlParams[navigateUrlParams.Length - 1]) != -1)
              {
                  item.Selected = true;
              }
          }
  </code></pre>
  
  <p>And in my mark up view I have this:</p>
  
  <pre><code> &lt;div class="clear hideSkiplink"&gt;
              &lt;asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal"  OnMenuItemClick="NavigationMenu_MenuItemClick"&gt;
                  &lt;Items&gt;
                      &lt;asp:MenuItem Text="Test1"/&gt;
                       &lt;asp:MenuItem Text="Test2"/&gt;
                       &lt;asp:MenuItem  Text="Test3"/&gt;
  
                  &lt;/Items&gt;
              &lt;/asp:Menu&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>So basically whenever user comes to Test1.aspx page, I want the menu item of Test1 to be highlighted. How should I do that?</p>
  
  <p>Any help will be appreciated! Thank you...</p>