5

I'm trying to add some menus to the "Quick Launch" navigation and it does not work. I'm using the following code:

var ql = myWeb.Navigation.QuickLaunch;
SPNavigationNode m1 = new SPNavigationNode("MainMenu", "");
ql.AddAsLast(m1);

SPNavigationNode m2 = new SPNavigationNode("OptionMenu", @"http://www.google.com", true);

ql[ql.Count - 1].Children.AddAsLast(m2);
ql[ql.Count - 1].Update();

I can't for the life of me understand what the issue is. No menu is shown.

If I look with power-shell at the QuickLaunch I see the "MainMenu" and the "OptionMenu" in the navigation but nothing is displayed. The IsVisible property is true.

Any hints?

1
  • I think Navigation codes are different between Publishing and Team site. I can't confirm it. Go a quick Google. Commented Dec 19, 2011 at 15:18

1 Answer 1

5

I figure your problem is that you have not specified URL for MainMenu. As you notice all links in QuickLaunch has link associated with it. Specify a Url and it should work (I tested that locally).

1
  • perfect. is there any way to query straight (direct access) if i want to get items in those list that linked? Commented May 6, 2014 at 6:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.