SharePointAds TextOnly

Monday, 21 September 2009

Sharepoint:Add new link to Quick Launch, Programmatically and through site settings

We can add new link to Quick launch menu by two ways
i. By Site Setting
ii. By Programmatically



1. How to add new link by Site settings?
Follow the following steps:
a. Login by admin authentication
b. Goto Site Action -> Site Settings
c. Click on 'Quick Launch' under 'Look and Feel' section
d. Click on 'Select Heading' and add 'Web Address' where you want to redirect (I use '#' which redirects to default.aspx page)and then give new name for this new section in 'description' text box(I use 'Custom Menu').
e. Click on OK, this will create new section in Quick Launch menu
f. Then click on 'New Link', it will open new window
g. Provide web address, and description (I use '/MyCustomPage.aspx' and give name as 'My Custom Page', this name will displaying in Quick launch menu)
i. Then select heading from combo box, select 'Custom Menu' heading
j. click on OK button
k. Now click on Home or goto default.aspx page


2. How can we create Quick Launch menu Programmatically?
use following code:

SPWeb web = SPContext.Current.Site.RootWeb;
web.AllowUnsafeUpdates = true;

SPNavigationNodeCollection nodes = web.Navigation.QuickLaunch;
SPNavigationNode navNode = new SPNavigationNode("Custom Menu", "#", false);
nodes.AddAsFirst(navNode);

SPNavigationNode headerLink1 = new SPNavigationNode("My Custom Page", "/MyCustomPage.aspx", true);
nodes[0].Children.AddAsFirst(headerLink1);


This will create new section in Quick lauch menu..
Really soooo easy :)

4 comments:

  1. Hello,
    You have got a nice blog- I have a question
    regarding your "How can we create Quick Launch menu Programmatically?" Post.
    You have given the code for creating Quick Launch menu.
    Could you also please explain the implementation steps.
    it would be really helpful for me.

    Thanks again

    Reply
  2. Hii,

    You can insert this code anywhere as you want like you can insert this at feature receiver class if you want to create new quick launch link when your feature install or activated...

    Reply
  3. SoftProgrammerr

    I'm new to WSS3.0 and MOSS2007
    still don't digging on the platform.
    If you can explain more, like I exactly don't know what or where the feature receiver class is!

    Do I need to create a VS project ??


    Thanks again

    Reply
  4. Hello SoftProgrammerr,

    You need to created VS project, and create new empty SharePoint project add add feature receiver class for this feature.
    Check this link
    or this also helps
    or chat me on [email protected], i will help you in my free time.

    Reply