views:

151

answers:

1

I want to hide a quick launch node in a sharepoint site, but it's not working as expected. :(

My code is as under:

                using (SPSite spSiteTest = new SPSite(serverUrl))
                {

                    using (SPWeb mySite = spSiteTest.OpenWeb())
                {
                    SPNavigationNodeCollection quickLaunchNodes = mySite.Navigation.QuickLaunch;

                    SPNavigationNode navQuickNode = new SPNavigationNode("Title", "www.stackoverflow.com", true);


                    foreach (SPNavigationNode node in quickLaunchNodes)
                    {
                        if (node.Title == navQuickNode.Title)
                        {
                            node.Url = navQuickNode.Url;
                            node.IsVisible = isVisible;
                            node.Update();
                            //mySite.Update();
                            return;
                        }
                    }   

                    quickLaunchNodes.AddAsFirst(navQuickNode);

                }
            }

Am I missing something or is it a bug?

+1  A: 

You can delete the nodes like this:

node.Delete();
mySite.Update();

or check the ExcludeFromNavigation method mentioned in this post (its author suggests that not being able to hide a navigation node by setting IsVisible to false is a SharePoint bug, too).

Marek Grzenkowicz
I already took the DELETE path...!!
Manish