Programmatically Check if publishing is turned on SharePoint site
In some cases you might wanna check the SharePoint Website to see if the Publishing fetaure is turned on .. well here is a small snippet for that
Public void Checksite(SPweb web)
{
PublishingWeb publishingWeb = null;
if (PublishingWeb.IsPublishingWeb(web))
{
publishingWeb = PublishingWeb.GetPublishingWeb(web);
}
else
{
throw new System.ArgumentException("The SPWeb " + web.Title + " is not a PublishingWeb", "web");
}
}
Note : This code was tested in SharePoint 2010. I guess should work in SharePoint 2007.
Public void Checksite(SPweb web)
{
PublishingWeb publishingWeb = null;
if (PublishingWeb.IsPublishingWeb(web))
{
publishingWeb = PublishingWeb.GetPublishingWeb(web);
}
else
{
throw new System.ArgumentException("The SPWeb " + web.Title + " is not a PublishingWeb", "web");
}
}
Note : This code was tested in SharePoint 2010. I guess should work in SharePoint 2007.
0 comments:
Post a Comment