Partilhar via


Web.GetSubwebsForCurrentUser Method

Returns the collection of child sites of the current site based on the specified query.

Namespace:  Microsoft.SharePoint.Client
Assemblies:   Microsoft.SharePoint.Client.Silverlight (in Microsoft.SharePoint.Client.Silverlight.dll);  Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)

Syntax

'Declaration
<RemoteAttribute> _
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_)
[RemoteAttribute]
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