Sometimes we have a requirement where we need to remove all customization from the PageLayout or from the Page. OOB SharePoint provide link to reset to site definition. But is someone needs to do that via code then below code will help them.
using (SPSite site = new SPSite("http://sharepoint2010"))
PublishingSite publishingSite = new PublishingSite(site);
PageLayoutCollection pageCollection = publishingSite.PageLayouts;
foreach (PageLayout layout in pageCollection)
SPFile currentFile = site.RootWeb.GetFile(layout.ServerRelativeUrl);
if (currentFile.CustomizedPageStatus == SPCustomizedPageStatus.Customized || currentFile.CustomizedPageStatus == SPCustomizedPageStatus.None)
catch (Exception ex)
Console.WriteLine("Error occuured : " + ex.Message);
Hope it will helps!!!
Post a Comment