ASP.NET Slide Menu - Knowledge Base

« Back to Knowledge Base list

How to hide a parent or child menu from client-side?

Q:

How to hide a parent or child menu from client-side?

A:

To do this, all parent & child must have their ID property set while declaring. To hide a parent or child from client-side, the onload function of the window needs to be modified.

        <osm:SlideMenu ...>
            <menuitems>
                <osm:Parent ID="a">Company Home</osm:Parent>
                    <osm:Child ID="entertaiment">
                       ...
                    </osm:Child>
               <osm:Parent ID="b">System Tasks</osm:Parent>
                    <osm:Child ID="sysinfo">
                        ...
                    </osm:Child>
             </menuitems>
        </osm:Slidee
Mnu>

        ....

        <script type="text/javascript">
            var oldonload = window.onload;
            window.onload = function() {
                if (oldonload != null)
                    oldonload();
                document.getElementById('entertaiment').style.display = 'none';
                document.getElementById("b").style.display = 'none';
            }
        </script>


When a parent is hidden, it'll hide it's children as well.