Friday, January 25, 2013

SPWeb Class with SharePoint 2013

SPWeb Class represents a web site.

The AllWebs Property of the SPSite Class will return all web sites within the site collection.

SPSite sSiteCollection = new SPSite("http://shalvin");
foreach(SPWeb sw in sSiteCollection.AllWebs)
  listBox1.Items.Add("Root web ? " + sw.IsRootWeb);
  listBox1.Items.Add("  ");

The Webs property of SPWeb Calss will Return all the immediate child web sites beneath a web site.

SPcontext ctx = SPContext.Current;
SPSite site = ctx.Site;

SPWeb sw = sw.RootWeb; 

foreach(SPWeb child in sw.Webs)

No comments:

Post a Comment