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.