Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

Programmatically activate publishing feature on subsite

$
0
0

I am trying to activate the "SharePoint Server Publishing" feature of a sub-site. The process is that a user clicks a button and the following events take place:

  1. sub-site is provisioned
  2. custom pages added to "Site Pages" library
  3. activate "Publishing" feature
  4. other items done

Here is the code I am using to attempt to activate the "Publishing" feature:

Guid DefaultSiteSettingsFeatureGuid = new Guid("22a9ef51-737b-4ff2-9346-694633fe4416");
SPFeature feature = ChildWeb.Features[DefaultSiteSettingsFeatureGuid];
if (feature == null)
{
ChildWeb.Features.Add(DefaultSiteSettingsFeatureGuid);
}

When the code runs it breaks at step #3 and the feature is not activated. Why?

Thanks for the assistance.


Viewing all articles
Browse latest Browse all 11571

Trending Articles



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