Showing posts with label Sharepoint 2010 site and site collection. Show all posts
Showing posts with label Sharepoint 2010 site and site collection. Show all posts

Sunday, November 13, 2011

Enumerate Sites and Site Collections


The AllWebs property of the SPSite class returns all the Web sites within a site collection, including the top-level site and all subsites. The following example enumerates the titles of all the Web sites and lists in the current site collection.
SPSite oSiteCollection = SPContext.Current.Site;
SPWebCollection collWebsite = oSiteCollection.AllWebs;

for (int i = 0; i < collWebsite.Count; i++)
{
    using (SPWeb oWebsite = collWebsite[i])
    {
        SPListCollection collList = oWebsite.Lists;

        for (int j = 0; j < collList.Count; j++)
        {
            Label1.Text += SPEncode.HtmlEncode(collWebsite[i].Title) + "   "
                + SPEncode.HtmlEncode(collList[j].Title) + "<BR>";
        }
    }
}

Featured Posts

Kali Linux Remote Desktop: Access GNOME from Windows Using Native RDP

  Kali Linux + GNOME 50 + GNOME Remote Desktop + Windows Remote Desktop (MSTSC) Getting a full GNOME desktop remotely on Kali Linux can be ...