Friday, October 26, 2012

The Module SharePoint Project Item type


The SharePoint Developer Tools provide a SharePoint Project Item Type named Module, which
provides a layer of productivity on top of the CAML-based Module element. You can add a
new Module SharePoint Project Item Type to a SharePoint project using the Add New Item
dialog of Visual Studio 2010.

Add New Item SharePoint 2010

In addition to provisioning objects within the top-level site, activation of the
MainSite feature creates a simple navigation scheme by adding four links to the top link bar.
This is accomplished in the FeatureActivated method by using the server-side object model
to add four new SPNavigationNode objects to the TopNavigationBar property of the current
SPWeb object’s Navigation property.

public override void FeatureActivated(SPFeatureReceiverProperties properties)
            SPSite oSPSite = new SPSite("http://amit-pc");
            //Open Sharepoint Site
            SPWeb oSPWeb = oSPSite.OpenWeb();
            oSPWeb.AllowUnsafeUpdates = true;

            // create menu for custom site pages
            SPNavigationNodeCollection topNav = oSPWeb.Navigation.TopNavigationBar;
            topNav.AddAsLast(new SPNavigationNode("Page 1", "Module1/Sample.txt"));
            topNav.AddAsLast(new SPNavigationNode("Page 2", "Module1/Sample.txt"));
            topNav.AddAsLast(new SPNavigationNode("Page 3", "Module1/Sample.txt"));
            topNav.AddAsLast(new SPNavigationNode("Page 4", "Module1/Sample.txt"));

using the above given code we can get the navigation in the site as shown in the below given figure:

SharePoint 2010

No comments:

Post a Comment