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

How do I pro grammatically delete a link from quick launch?

$
0
0

Am trying to delete some links from the quickLaunch after a page has been created on Feature activation. Right now, once my page is created the link is added to the quick launch and i am trying to add an event receiver which would delete this link from the quick launch. So far this is what I have been able to come up with, but this code still isn't working. I think am over doing something here...any ideas on what am doing wrong and how i can get this code to work?

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{                
    SPSecurity.RunWithElevatedPrivileges(delegate()
	{
		SPSite site = SPContext.Current.Site;
		SPWeb myWeb = site.RootWeb;
		using (SPSite siteCollection = new SPSite(site.ID))
		{
			using (SPWeb web = siteCollection.OpenWeb(myWeb.ID))
			{
				web.AllowUnsafeUpdates = true;
				SPNavigationNodeCollection nodes = web.Navigation.QuickLaunch;
				foreach (SPNavigationNode node in nodes)
				{
					if (node.Title.ToString() == "First Page" || node.Title.ToString() == "Second Page" || node.Title.ToString() == "Third Page")
					{
						node.Delete();
					}
				}
			}
		}
	});
}


I appreciate the input...thanks.



Viewing all articles
Browse latest Browse all 11508

Trending Articles



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