Share via


Web.GetSubwebsForCurrentUser method

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)

Syntax

'Declaration
Public Function GetSubwebsForCurrentUser ( _
    query As SubwebQuery _
) As WebCollection
'Usage
Dim instance As Web
Dim query As SubwebQuery
Dim returnValue As WebCollection

returnValue = instance.GetSubwebsForCurrentUser(query)
public WebCollection GetSubwebsForCurrentUser(
    SubwebQuery query
)

Parameters

Return value

Type: Microsoft.SharePoint.Client.WebCollection
Returns WebCollection.

Remarks

If the query is not valid, the server must return an empty collection.

Examples

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);
        }
    }
}

See also

Reference

Web class

Web members

Microsoft.SharePoint.Client namespace