Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

add link to on the left navigation c#

$
0
0

Hi there am trying add links to left nav . I have this code but i cant get it to work as i get Object reference not set to an instance of an object.

Thanks kindly. 

using (SPSite site = new SPSite("http://site"))
                {
                    using (SPWeb web = site.RootWeb)
                    {
                        web.AllowUnsafeUpdates = true;
                        Microsoft.SharePoint.Navigation.SPNavigation sp = web.Navigation;
                        SPNavigationNode spn1 = new SPNavigationNode("some-title", "", true);
                        sp.QuickLaunch.AddAsFirst(spn1); //add to level1
                        web.Update();
                    }
                }


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>