Web::GetSubwebsForCurrentUser method
SharePoint Online
Returns the collection of child sites of the current site based on the specified query.
Namespace: Microsoft.SharePoint.Client
Assembly: Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)
Parameters
- query
- Type: Microsoft.SharePoint.Client.SubwebQuery
Specifies which child sites to return.
This code example displays the titles of the child sites of the specified site.
using System; using Microsoft.SharePoint.Client; namespace Microsoft.SDK.SharePointFoundation.Samples { class WebGetSubwebsExample { static void Main() { string siteUrl = "http://MyServer/sites/MySiteCollection"; ClientContext clientContext = new ClientContext(siteUrl); Web site = clientContext.Web; WebCollection collWeb = site.GetSubwebsForCurrentUser(null); clientContext.Load(collWeb); clientContext.ExecuteQuery(); Console.WriteLine("Child sites: \n\n"); foreach (Web oneWeb in collWeb) Console.WriteLine(oneWeb.Title); } } }
Show: