1

I am using Bootstrap Treeview from my ASP.NET master page. Please see the sample code below. This code is in a Master page. The treeview is losing its state when going to a child page (for example, Page5). The menu gets collapsed.

What would be the best way to keep the respective treeview expanded? For example, when I go to Page 3, I want to have the secondMenuli expanded.

NOTE: I tried it without master page and it works perfectly, but I was looking to solve it using the master page.

<ul id="leftmenulist" class="sidebar-menu">
  <li id="firstMenuli" class="active">
      <a href="Home.aspx">
          <span>Home</span>
      </a>
  </li>
  <li id="secondMenuli" class="treeview">
      <a href="#">
        <span>Second Menu</span>
      </a>
      <ul class="treeview-menu">
        <li><a href="Page1.aspx">Page1</a></li>
        <li><a href="Page2.aspx">Page2</a></li>
        <li><a href="Page3.aspx">Page3</a></li>
      </ul>
  </li>
  <li id="thirdMenuli" class="treeview">
      <a href="#">
        <span>Third Menu</span>
      </a>
      <ul class="treeview-menu">
        <li><a href="Page4.aspx">Page4</a></li>
        <li><a href="Page5.aspx">Page5</a></li>
        <li><a href="Page6.aspx">Page6</a></li>
      </ul>
  </li>
</ul>
James A Mohler
  • 11,060
  • 15
  • 46
  • 72
Murad
  • 11
  • 4
  • Set a cookie as to which treeview is open. When you switch the page have it look for the cookie and open the treeview. – Wild Beard Jan 11 '15 at 08:02
  • Hi, thank you for your response. As the treeview get collapsed everytime and I know which page I am in every time I go to a new page, I may not need to set a cookie. Instead set the Treeview expanded (required tab) forcefully after page load. But I am wondering how I can access the masterpage control (the treeview, which is actually a list item) in to the child page and then expand it. – Murad Jan 12 '15 at 16:43

0 Answers0