{ using (SPWeb web = site.RootWeb) { // Check in all files in the branding folder so that they will be applied properly SPFolder altStyleFolder = web.GetFolder(CONTOSO_BRANDING_FOLDER); foreach (SPFile styleFile in altStyleFolder.Files) { if (styleFile.CheckOutType != SPFile.SPCheckOutType.None) { styleFile.CheckIn("Checked in via feature activation.", SPCheckinType.MajorCheckIn); } } // also check in and approve the master page string contosoMasterUrl = CreateMasterPageUrl(web, CONTOSO_MASTER); SPFile contosoMaster = web.GetFile(contosoMasterUrl); if (contosoMaster.CheckOutType != SPFile.SPCheckOutType.None) { contosoMaster.CheckIn("Checked in via feature activation.", SPCheckinType.MajorCheckIn); contosoMaster.Approve("Approved via feature activation."); } // set new master page web.CustomMasterUrl = contosoMasterUrl; web.MasterUrl = contosoMasterUrl; web.Update(); } } } Replace the commented out FeatureDeactivating method with the code below to undo the modifications made when the feature was activated by clearing out the alternate css and site logo before returning to the original branding. (Code snippet 8.2.13) C# /// <summary> /// Custom code that runs before the feature is deactivated /// </summary> /// <param name="properties"></param> public override void FeatureDeactivating(SPFeatureReceiverProperties properties) {
{ using (SPWeb web = site.RootWeb) { // Check in all files in the branding folder so that they will be applied properly SPFolder altStyleFolder = web.GetFolder(CONTOSO_BRANDING_FOLDER); foreach (SPFile styleFile in altStyleFolder.Files) { if (styleFile.CheckOutType != SPFile.SPCheckOutType.None) { styleFile.CheckIn("Checked in via feature activation.", SPCheckinType.MajorCheckIn); } } // also check in and approve the master page string contosoMasterUrl = CreateMasterPageUrl(web, CONTOSO_MASTER); SPFile contosoMaster = web.GetFile(contosoMasterUrl); if (contosoMaster.CheckOutType != SPFile.SPCheckOutType.None) { contosoMaster.CheckIn("Checked in via feature activation.", SPCheckinType.MajorCheckIn); contosoMaster.Approve("Approved via feature activation."); } // set new master page web.CustomMasterUrl = contosoMasterUrl; web.MasterUrl = contosoMasterUrl; web.Update(); } } } Replace the commented out FeatureDeactivating method with the code below to undo the modifications made when the feature was activated by clearing out the alternate css and site logo before returning to the original branding. (Code snippet 8.2.13) C# /// <summary> /// Custom code that runs before the feature is deactivated /// </summary> /// <param name="properties"></param> public override void FeatureDeactivating(SPFeatureReceiverProperties properties) {