Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Sunday, January 22, 2012

Precautions needed while looping through publishing site subsites

In publishing site you have the additional sites like Document center, News,Reports,Search and sites. While retrieving data from subsites you should stop looping of these subsites like this.

spweb currentweb=spcontext.current.web;
foreach(spweb objSite in currentweb.GetSubwebsForCurrentUser())
{
     if (objSite.Title != "Document Center" && objSite.Title != "News" && objSite.Title != "Reports" && objSite.Title != "Search" && objSite.Title != "Sites")
     {
         //Write your code here.
     }

}



No comments:

Post a Comment