Here we will discuss about how to Get default page layout of a publishing web site in SharePoint 2010.
Also you can check out:
- SharePoint 2010 boundaries and limits of Microsoft SharePoint Server 2010
- Delete SharePoint List using PowerShell
- Difference between SharePoint-hosted, auto-hosted and Provider-hosted apps in SharePoint 2013
Below SharePoint 2010 object model code that is used to get the default page layout of a publishing web site in SharePoint 2010. Site URL is the site collection URL.
private static void GetDefaultPageLayout()
{
using (SPSite site = new SPSite("Site URL"))
{
using (SPWeb web = site.OpenWeb())
{
// Get the publishing web site
PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
PageLayout pageLayout = publishingWeb.DefaultPageLayout;
Console.WriteLine("Default Page Layout Name"+pageLayout.Name + " URL of the web site : " + pageLayout.ServerRelativeUrl);
}
}
}
Also you can check out:
- SharePoint 2010 boundaries and limits of Microsoft SharePoint Server 2010
- Delete SharePoint List using PowerShell
- Difference between SharePoint-hosted, auto-hosted and Provider-hosted apps in SharePoint 2013
Below SharePoint 2010 object model code that is used to get the default page layout of a publishing web site in SharePoint 2010. Site URL is the site collection URL.
private static void GetDefaultPageLayout()
{
using (SPSite site = new SPSite("Site URL"))
{
using (SPWeb web = site.OpenWeb())
{
// Get the publishing web site
PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
PageLayout pageLayout = publishingWeb.DefaultPageLayout;
Console.WriteLine("Default Page Layout Name"+pageLayout.Name + " URL of the web site : " + pageLayout.ServerRelativeUrl);
}
}
}