title: Highlight active menu items in master page
body: <p>I am using a master for my menu items. Since I am using master page, I am confused how to highlight active menu item. Can anyone help me out. Since I have 4 pages, I tried this below code in all page load event in 4 pages and didn't work.</p>
  
  <pre><code>if (!IsPostBack)
          {
              Menu M = (Menu)this.Master.FindControl("menu");
              foreach (MenuItem item in M.Items)
              {
                  if (item.Text == "update")
                  {
                      item.Selected = true;
                  }
              }
          }
  
   &lt;div id="menu"&gt;
                  &lt;ul&gt;
                      &lt;li&gt;
                          &lt;asp:LinkButton ID="update"  runat="server"  OnClick="update_Click"&gt;Update&lt;/asp:LinkButton&gt;&lt;/li&gt;
                      &lt;li&gt;
                          &lt;asp:LinkButton ID="bulk" runat="server" OnClick="bulkupdate_Click"&gt;Bulk&lt;/asp:LinkButton&gt;&lt;/li&gt;
                      &lt;li&gt;
                          &lt;asp:LinkButton ID="profiles" runat="server" OnClick="userprofiles_Click"&gt;Profiles&lt;/asp:LinkButton&gt;&lt;/li&gt;
                      &lt;li&gt;
                          &lt;asp:LinkButton ID="help" runat="server" OnClick="help_Click"&gt;Help&lt;/asp:LinkButton&gt;&lt;/li&gt;
                  &lt;/ul&gt;
              &lt;/div&gt;
  
  #menu ul {
  margin: 0;
  padding: 7px 6px 0;
  background: #b6b6b6 url('/Images/Overlay.png') repeat-x 0 -110px;
  line-height: 100%;
  border-radius: 1em;
  font: normal 0.5333333333333333em Arial, Helvetica, sans-serif;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  border-radius: 5px;
  -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  width 100%;
  }
  #menu li {
  margin: 0 5px;
  padding: 0 0 8px;
  float: left;
  position: relative;
  list-style: none;
  }
  #menu a,
  #menu a:link {
  font-weight: bold;
  font-size: 16px;
  color: #444444;
  text-decoration: none;
  display: block;
  padding: 8px 20px;
  margin: 0;
  border-radius: 5px;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
  }
  #menu a:hover {
  background: #000;
  color: #fff;
  }
  #menu .active a,
  #menu li:hover &gt; a {
  background: #bdbdbd url('/Images/Overlay.png') repeat-x 0 -40px;
  background: #666666 url('/Images/Overlay.png') repeat-x 0 -40px;
  color: #444;
  border-top: solid 1px  #f8f8f8;
  -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
  -moz-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
  text-shadow: 0 1px 0 #ffffff;
  }
  #menu ul ul li:hover a,
  #menu li:hover li a {
  background: none;
  border: none;
  color: #666;
  -webkit-box-shadow: none;
  -moz-box-shadow: none;
  }
  #menu ul ul a:hover {
  background: #7d7d7d url('/Images/Overlay.png') repeat-x 0 -100px !important;
  color: #fff !important;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  border-radius: 5px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
  }
  #menu li:hover &gt; ul {
  display: block;
  }
  #menu ul ul {
  display: none;
  margin: 0;
  padding: 0;
  width: 185px;
  position: absolute;
  top: 40px;
  left: 0;
  background: url('/Images/Overlay.png') repeat-x 0 0;
  border: solid 1px #b4b4b4;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  border-radius: 5px;
  -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  }
  #menu ul ul li {
  float: none;
  margin: 0;
  padding: 3px;
  }
  #menu ul ul a,
  #menu ul ul a:link {
  font-weight: normal;
  font-size: 12px;
  }
  #menu ul:after {
  content: '.';
  display: block;
  clear: both;
  visibility: hidden;
  line-height: 0;
  height: 0;
  }
  * html #menu ul {
  height: 1%;
  }
  </code></pre>