2

I want to change the current navigation to "Structural Navigation: Display only the navigation items below the current site" of sub site. I got this which shows how to set the current navigation and based on that I developed code as below:

static void Main(string[] args)
{
    using(SPSite site= new SPSite("http://............"))
    {
        string val = null;
        Console.WriteLine(site.Url);

        SPWeb web = site.AllWebs["Depts"];
        if (web != null)
        {
            Console.WriteLine(web.Url);
            PublishingWeb my = PublishingWeb.GetPublishingWeb(web);
            WebNavigationSettings navigationSettings = new WebNavigationSettings(web);
            navigationSettings.CurrentNavigation.Source = StandardNavigationSource.Unknown;
            my.Navigation.CurrentIncludePages = false;
            my.Navigation.CurrentIncludeSubSites = false;
            navigationSettings.Update();
            my.Update();
        }
        Console.WriteLine("Completed..");
        Console.ReadKey();
        web.Dispose();
    }
}

But when I run the code I am getting the error at line:navigationSettings.CurrentNavigation.Source = StandardNavigationSource.Unknown; that indicates "The value "Unknown" is not allowed for property type "StandardNavigationSource"."

What am I missing?

2

that is strange! when your writing your code and you enter StandardNavigationSource and then add . (decimal) does it come out with a list of options? also i know more than likely you have but have you add the following references withinn the project and top of class?

web.Navigation (Namespace: Microsoft.SharePoint)
publishingWeb.Navigation (Namespace: Microsoft.SharePoint.Publishing)
WebNavigationSettings (Namespace: Microsoft.SharePoint.Publishing.Navigation)

also are you sure its ment to be that? and not:

        PublishingWeb my = PublishingWeb.GetPublishingWeb(web);
        WebNavigationSettings navigationSettings = new WebNavigationSettings(web);
        navigationSettings.GlobalNavigation.Source = StandardNavigationSource.Unknown;

There are two navigations. The Global navigation (also called Top navigation) and the Current navigation (also called left navigation or quicklaunch). Both of these can be set to different to use different sources. They can inherit from their parent (if a subsite only), use managed navigation, or structural navigation. All you need to do is select the webNavigationSettings object, choose which navigation to set, and select a source for that navigation.

so it is the quick launch that your trying to ammend ;), i know that you probably are, im just making sure!

more importantly I would also like to note from msdn on the error your getting:

This property determines whether the switchable site map provider will use the taxonomy site map provider or the portal site map provider in the standard configurations. If the settings are in an advanced configuration, then this property returns StandardNavigationSource.Unknown (section 3.1.5.11.1.1). If the protocol client attempts to assign the StandardNavigationSource.Unknown value to this property, the protocol server MUST return an InvalidOperationException error.

going to section 3.1.5.10.1.1 will show:

Indicates that the navigation scheme is in an advanced configuration that does not correspond to one of the standard configurations.

  • Thanks for reply sir, I added all the assemblies and also the intelligent box shows the option of selecting unknown. But when I run the program I get the error. – users1100 Nov 28 '13 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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