Thursday, August 25, 2011

Client Object Model In SharePoint 2010



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ClientOM = Microsoft.SharePoint.Client;

namespace SharePointList
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void ShowButton_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            ListsListBox.Items.Clear();
            using(ClientOM.ClientContext ctx=new ClientOM.ClientContext(UrlTextBox.Text))
            {
                ClientOM.Web site=ctx.Web;
                ctx.Load(site);
                ctx.Load(site.Lists);
                ctx.ExecuteQuery();
                foreach (ClientOM.List list in site.Lists)
                {
                    ListsListBox.Items.Add(list.Title);
                    this.Cursor = Cursors.Default;
                }
            }
        }
    }
}

No comments:

Post a Comment

Featured Post

Mention a Channel or Team – Power Automate

Mention a Channel or Team – Power Automate graph.microsoft.com/v1.0/teams/{teamId}/channels/{channelId}/messages Channel: ---------- {   &qu...

Popular posts