Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

How to edit the navigation settings using sandboxed code?

$
0
0

Hello. I need to create web-provisioned event that changes current navigation settings to "Structural Navigation: Display the current site, the navigation items below the current site, and the current site's siblings".

Currently I am using following code which does not work (I used SharePont manager to get the xml for _webnavigationsettings).

        public const string Webnavigationsettings = "_webnavigationsettings";
        public const string GlobalNavigationIncludeTypes = "__GlobalNavigationIncludeTypes";       

 protected void Button1_Click(object sender, EventArgs e)
        {
            SPWeb web = SPContext.Current.Web;

            const string webnavigationsettings = @"<?xml version='1.0' encoding='utf-16' standalone='yes'?><WebNavigationSettings Version='1.1'><SiteMapProviderSettings><SwitchableSiteMapProviderSettings Name='CurrentNavigationSwitchableProvider' TargetProviderName='CurrentNavigation' /><TaxonomySiteMapProviderSettings Name='CurrentNavigationTaxonomyProvider' Disabled='True' /><SwitchableSiteMapProviderSettings Name='GlobalNavigationSwitchableProvider' UseParentSiteMap='True' /><TaxonomySiteMapProviderSettings Name='GlobalNavigationTaxonomyProvider' UseParentSiteMap='True' /></SiteMapProviderSettings><NewPageSettings AddNewPagesToNavigation='True' CreateFriendlyUrlsForNewPages='True' /></WebNavigationSettings>";

            if (web.GetProperty(Webnavigationsettings) != null)
                web.DeleteProperty(Webnavigationsettings); 

            web.AddProperty(Webnavigationsettings, webnavigationsettings);

            if (web.GetProperty(GlobalNavigationIncludeTypes) != null)
                web.DeleteProperty(GlobalNavigationIncludeTypes);

            web.AddProperty(GlobalNavigationIncludeTypes, 3);

            web.Update();
        }
I can do this with javascript but what about sandboxed c#?  


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>