Condividi tramite


View Class

Specifies a list view.

Inheritance Hierarchy

System.Object
  Microsoft.SharePoint.Client.ClientObject
    Microsoft.SharePoint.Client.View

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
<ScriptTypeAttribute("SP.View", ServerTypeId := "{2399f45d-1784-4965-9a5f-a3415790a0d0}")> _
Public Class View _
    Inherits ClientObject
'Usage
Dim instance As View
[ScriptTypeAttribute("SP.View", ServerTypeId = "{2399f45d-1784-4965-9a5f-a3415790a0d0}")]
public class View : ClientObject

Examples

This code example orders the items on the Tasks list of the specified site in descending alphabetic order.

using System;
using Microsoft.SharePoint.Client;

namespace Microsoft.SDK.SharePointFoundation.Samples
{
    class ViewExample
    {
        static void Main()
        {
            string siteUrl = "http://MyServer/sites/MySiteCollection";

            ClientContext clientContext = new ClientContext(siteUrl);
            Web site = clientContext.Web;

            List targetList = site.Lists.GetByTitle("Tasks");
            ViewCollection collView = targetList.Views;
            View targetView = collView.GetByTitle("All Tasks");
            string strQuery = "<OrderBy><FieldRef Name=\'Title\' Ascending=\'False\' /></OrderBy>";
            targetView.ViewQuery = strQuery;
            targetView.Update();

            clientContext.ExecuteQuery();

            Console.WriteLine("Tasks list ordered in descending alphabetic order.");
        }
    }
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

View Members

Microsoft.SharePoint.Client Namespace