ASP.NET Slide Menu - Knowledge Base

« Back to Knowledge Base list

Expand some parent menus only

Q:

I have a SlideMenu with three parent menus. How to expand the first two parent menus on page load?
The ALLExpanded property allows to expand all parent menus on page load, but I want the first two ones be expanded only.

A:

Here is the code sample:

<form id="Form1" runat="server">
  <asp:ScriptManager runat="server" ID="scriptManager" />
  <osm:SlideMenu id = "pro_1" KeepExpanded="true"
                           runat = "server" AutoPostback="true"
                           StyleFolder="styles/pro_1">
     <menuitems>
         <osm:Parent id="parent1">Company Home</osm:Parent>
              <osm:Child>Entertainment</osm:Child>
              <osm:Child>Games</osm:Child>
              <osm:Child>Greeting Cards</osm:Child>
              <osm:Child>Downloads</osm:Child>
         <osm:Parent id="parent2">System Tasks</osm:Parent>
              <osm:Child>View system info</osm:Child>
              <osm:Child>Add programs</osm:Child>
              <osm:Child>Change settings</osm:Child>
              <osm:Child>Add users</osm:Child>
         <osm:Parent id="parent3">Obout controls</osm:Parent>
              <osm:Child>Slide menu</osm:Child>
              <osm:Child>Grid</osm:Child>
              <osm:Child>HTML Editor</osm:Child>
              <osm:Child>FileUpload</osm:Child>
     </menuitems>
  </osm:SlideMenu>
  <script type="text/javascript">
     function pageLoad(sender, args) {
        //------------------------------------------------------------------------
        // The slide menu client side object can be accessed by oboutSM{id} object
        // where {id} indicates the ID of the slide menu
        //------------------------------------------------------------------------
 
        // expand the first parent
        oboutSMpro_1.parentClick("parent1");
 
        // expand the second parent with a  little delay - the first expanding must be finished
        setTimeout(function () { oboutSMpro_1.parentClick("parent2"); }, 100);
     }
  </script>
</form>