Search This Blog

Monday, December 22, 2014

SharePoint Custom SiteActionMenu- Navigate Custom Application Page

Step 1: Create Sharepoint Project
Step 2: Add New Item Select Elements
Step 3: Peaste the below content and deploy the site
Step 4: Go to SiteActionMenu you have seen the News Page Menu.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
     Id="MyCustomAction"
     Description="Navigate custom Application Page."
     Title="News Page"
     GroupId="SiteActions"
     Location="Microsoft.SharePoint.StandardMenu"
     ImageUrl="/_Layouts/Images/images.jpg"
     Sequence="10">
    <UrlAction Url="/_layouts/Pages/News.aspx"/>
  </CustomAction>
</Elements>

Thursday, December 4, 2014

SharePoint2010.CustomNavigation using FeatureEvent Receiver

Download Source : Custom Navigation Sharepoint 2010


using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Navigation;

namespace SharePoint2010.CustomNavigation.Features.CustomNavigationFeature
{
    /// <summary>
    /// This class handles events raised during feature activation, deactivation, installation, uninstallation, and upgrade.
    /// </summary>
    /// <remarks>
    /// The GUID attached to this class may be used during packaging and should not be modified.
    /// </remarks>

    [Guid("87c29feb-c8e8-4a1f-8a8d-2cae3122c241")]
    public class CustomNavigationFeatureEventReceiver : SPFeatureReceiver
    {
        // Uncomment the method below to handle the event raised after a feature has been activated.

        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPWeb currentWeb = (SPWeb)properties.Feature.Parent;


            #region addding the departments node
            SPNavigationNode DepartmentsNode = new SPNavigationNode("Departments", "#", true);
            DepartmentsNode = currentWeb.Navigation.TopNavigationBar.AddAsLast(DepartmentsNode);
            DepartmentsNode.Properties.Add("NodeType", "Heading");
            DepartmentsNode.Update();

            //adding Administration
            SPNavigationNode AdministrationNode = new SPNavigationNode("Administration", "/Pages/default.aspx", true);
            DepartmentsNode.Children.AddAsFirst(AdministrationNode);
            AdministrationNode.Update();

            //adding Maintenance
            SPNavigationNode MaintenanceNode = new SPNavigationNode("Maintenance", "/Pages/default.aspx", true);
            DepartmentsNode.Children.AddAsFirst(MaintenanceNode);
            MaintenanceNode.Update();

            //adding Operations
            SPNavigationNode OperationsNode = new SPNavigationNode("Operations", "/Pages/default.aspx", true);
            DepartmentsNode.Children.AddAsLast(OperationsNode);
            OperationsNode.Update();

            //adding Technical and Process Engineering
            SPNavigationNode TechPENode = new SPNavigationNode("Technical and Process Engineering", "/Pages/default.aspx", true);
            DepartmentsNode.Children.AddAsLast(TechPENode);
            TechPENode.Update();

            //adding BPF
            SPNavigationNode BPFNode = new SPNavigationNode("Business Planning and Finance", "/Pages/default.aspx", true);
            DepartmentsNode.Children.AddAsLast(BPFNode);
            BPFNode.Update();

            //adding Maintenance
            SPNavigationNode SupplyChainNode = new SPNavigationNode("Supply Chain", "/Pages/default.aspx", true);
            DepartmentsNode.Children.AddAsLast(SupplyChainNode);
            SupplyChainNode.Update();

            //adding Operations
            SPNavigationNode ISDNode = new SPNavigationNode("IsS", "Pages/default.aspx", true);
            DepartmentsNode.Children.AddAsLast(ISDNode);
            ISDNode.Update();

            //adding Technical and Process Engineering
            SPNavigationNode ITNode = new SPNavigationNode("IT", "Pages/default.aspx", true);
            DepartmentsNode.Children.AddAsLast(ITNode);
            ITNode.Update();

            //adding BPF
            SPNavigationNode NIPRASNode = new SPNavigationNode("NsdsIPRAS", "Pages/default.aspx", true);
            DepartmentsNode.Children.AddAsLast(NIPRASNode);
            NIPRASNode.Update();
            #endregion
        }


        // Uncomment the method below to handle the event raised before a feature is deactivated.

        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            //delete the top navigation when deactivate..
            SPWeb currentWeb = (SPWeb)properties.Feature.Parent;
            SPNavigationNodeCollection nodes = currentWeb.Navigation.TopNavigationBar;
            for (int i = nodes.Count - 1; i >= 0; i--)
            {
                nodes[i].Delete();
            }
            currentWeb.Update();
            currentWeb.AllowUnsafeUpdates = false;

        }


        // Uncomment the method below to handle the event raised after a feature has been installed.

        //public override void FeatureInstalled(SPFeatureReceiverProperties properties)
        //{
        //}


        // Uncomment the method below to handle the event raised before a feature is uninstalled.

        //public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
        //{
        //}

        // Uncomment the method below to handle the event raised when a feature is upgrading.

        //public override void FeatureUpgrading(SPFeatureReceiverProperties properties, string upgradeActionName, System.Collections.Generic.IDictionary<string, string> parameters)
        //{
        //}
    }
}