Click here to Skip to main content
15,885,278 members
Articles / Web Development / ASP.NET

SharePoint 2010 Client Object Model: Introduction

Rate me:
Please Sign up or sign in to vote.
4.83/5 (17 votes)
6 Jun 2012CPOL6 min read 260.5K   4.4K   24  
An overview of the Client Object Model in SharePoint 2010.
namespace ClientObjectModel.Examples
{
    partial class MainForm
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.SiteInfoButton = new System.Windows.Forms.Button();
            this.ServerText = new System.Windows.Forms.TextBox();
            this.ListInfoButton = new System.Windows.Forms.Button();
            this.GetListDataButton = new System.Windows.Forms.Button();
            this.datagrid = new System.Windows.Forms.DataGridView();
            this.UpdateTitleButton = new System.Windows.Forms.Button();
            this.CriteriaButton = new System.Windows.Forms.Button();
            this.GetByPageSizeButton = new System.Windows.Forms.Button();
            this.InsertButton = new System.Windows.Forms.Button();
            this.button4 = new System.Windows.Forms.Button();
            this.ReduceResultSizeButton = new System.Windows.Forms.Button();
            this.ReduceSizeListItemsButton = new System.Windows.Forms.Button();
            this.UpdateButton = new System.Windows.Forms.Button();
            this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
            this.CredentialsButton = new System.Windows.Forms.Button();
            ((System.ComponentModel.ISupportInitialize)(this.datagrid)).BeginInit();
            this.SuspendLayout();
            // 
            // SiteInfoButton
            // 
            this.SiteInfoButton.Location = new System.Drawing.Point(12, 41);
            this.SiteInfoButton.Name = "SiteInfoButton";
            this.SiteInfoButton.Size = new System.Drawing.Size(252, 43);
            this.SiteInfoButton.TabIndex = 0;
            this.SiteInfoButton.Text = "Get Site Information";
            this.toolTip1.SetToolTip(this.SiteInfoButton, "Returns the Title and Descriptionn of the Site");
            this.SiteInfoButton.UseVisualStyleBackColor = true;
            this.SiteInfoButton.Click += new System.EventHandler(this.SiteInfoButton_Click);
            // 
            // ServerText
            // 
            this.ServerText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.ServerText.Location = new System.Drawing.Point(12, 12);
            this.ServerText.Name = "ServerText";
            this.ServerText.Size = new System.Drawing.Size(714, 20);
            this.ServerText.TabIndex = 1;
            this.ServerText.Text = "http://localhost";
            this.toolTip1.SetToolTip(this.ServerText, "Enter the URL of the site");
            // 
            // ListInfoButton
            // 
            this.ListInfoButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
            this.ListInfoButton.Location = new System.Drawing.Point(12, 90);
            this.ListInfoButton.Name = "ListInfoButton";
            this.ListInfoButton.Size = new System.Drawing.Size(252, 43);
            this.ListInfoButton.TabIndex = 0;
            this.ListInfoButton.Text = "Get List Information";
            this.toolTip1.SetToolTip(this.ListInfoButton, "Returns the Lists inside the Site along with their Names");
            this.ListInfoButton.UseVisualStyleBackColor = false;
            this.ListInfoButton.Click += new System.EventHandler(this.ListInfoButton_Click);
            // 
            // GetListDataButton
            // 
            this.GetListDataButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
            this.GetListDataButton.Location = new System.Drawing.Point(12, 139);
            this.GetListDataButton.Name = "GetListDataButton";
            this.GetListDataButton.Size = new System.Drawing.Size(252, 43);
            this.GetListDataButton.TabIndex = 2;
            this.GetListDataButton.Text = "Get Tasks Data - Id, Title, Status using CAML";
            this.toolTip1.SetToolTip(this.GetListDataButton, "Returns the Items from the List named Tasks");
            this.GetListDataButton.UseVisualStyleBackColor = false;
            this.GetListDataButton.Click += new System.EventHandler(this.GetListDataButton_Click);
            // 
            // datagrid
            // 
            this.datagrid.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.datagrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.datagrid.Location = new System.Drawing.Point(270, 41);
            this.datagrid.Name = "datagrid";
            this.datagrid.Size = new System.Drawing.Size(456, 637);
            this.datagrid.TabIndex = 3;
            // 
            // UpdateTitleButton
            // 
            this.UpdateTitleButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
            this.UpdateTitleButton.Location = new System.Drawing.Point(12, 188);
            this.UpdateTitleButton.Name = "UpdateTitleButton";
            this.UpdateTitleButton.Size = new System.Drawing.Size(252, 43);
            this.UpdateTitleButton.TabIndex = 2;
            this.UpdateTitleButton.Text = "Update Title";
            this.toolTip1.SetToolTip(this.UpdateTitleButton, "Updates the Title of Tasks items whose Id is an even number\r\n");
            this.UpdateTitleButton.UseVisualStyleBackColor = false;
            this.UpdateTitleButton.Click += new System.EventHandler(this.UpdateTitleButton_Click);
            // 
            // CriteriaButton
            // 
            this.CriteriaButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
            this.CriteriaButton.Location = new System.Drawing.Point(12, 286);
            this.CriteriaButton.Name = "CriteriaButton";
            this.CriteriaButton.Size = new System.Drawing.Size(252, 43);
            this.CriteriaButton.TabIndex = 2;
            this.CriteriaButton.Text = "Get By Criteria";
            this.toolTip1.SetToolTip(this.CriteriaButton, "Get results by Search Criteria");
            this.CriteriaButton.UseVisualStyleBackColor = false;
            this.CriteriaButton.Click += new System.EventHandler(this.CriteriaButton_Click);
            // 
            // GetByPageSizeButton
            // 
            this.GetByPageSizeButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
            this.GetByPageSizeButton.Location = new System.Drawing.Point(12, 237);
            this.GetByPageSizeButton.Name = "GetByPageSizeButton";
            this.GetByPageSizeButton.Size = new System.Drawing.Size(252, 43);
            this.GetByPageSizeButton.TabIndex = 2;
            this.GetByPageSizeButton.Text = "Get By RowLimit :  3 Items";
            this.toolTip1.SetToolTip(this.GetByPageSizeButton, "Restricts Result Set by 3 Items using the XML Tag RowLimit");
            this.GetByPageSizeButton.UseVisualStyleBackColor = false;
            this.GetByPageSizeButton.Click += new System.EventHandler(this.GetByPageSizeButton_Click);
            // 
            // InsertButton
            // 
            this.InsertButton.BackColor = System.Drawing.Color.White;
            this.InsertButton.Location = new System.Drawing.Point(12, 335);
            this.InsertButton.Name = "InsertButton";
            this.InsertButton.Size = new System.Drawing.Size(252, 43);
            this.InsertButton.TabIndex = 4;
            this.InsertButton.Text = "Insert an Item";
            this.toolTip1.SetToolTip(this.InsertButton, "Insert an Item through Code");
            this.InsertButton.UseVisualStyleBackColor = false;
            this.InsertButton.Click += new System.EventHandler(this.InsertButton_Click);
            // 
            // button4
            // 
            this.button4.BackColor = System.Drawing.Color.White;
            this.button4.Location = new System.Drawing.Point(12, 434);
            this.button4.Name = "button4";
            this.button4.Size = new System.Drawing.Size(252, 43);
            this.button4.TabIndex = 4;
            this.button4.Text = "Delete an Item";
            this.toolTip1.SetToolTip(this.button4, "Delete an Item");
            this.button4.UseVisualStyleBackColor = false;
            this.button4.Click += new System.EventHandler(this.button4_Click);
            // 
            // ReduceResultSizeButton
            // 
            this.ReduceResultSizeButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(192)))));
            this.ReduceResultSizeButton.Location = new System.Drawing.Point(12, 483);
            this.ReduceResultSizeButton.Name = "ReduceResultSizeButton";
            this.ReduceResultSizeButton.Size = new System.Drawing.Size(252, 43);
            this.ReduceResultSizeButton.TabIndex = 2;
            this.ReduceResultSizeButton.Text = "Reducing Result Size";
            this.toolTip1.SetToolTip(this.ReduceResultSizeButton, "Reducing Result Size by specifying columns");
            this.ReduceResultSizeButton.UseVisualStyleBackColor = false;
            this.ReduceResultSizeButton.Click += new System.EventHandler(this.ReduceResultSizeButton_Click);
            // 
            // ReduceSizeListItemsButton
            // 
            this.ReduceSizeListItemsButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(192)))));
            this.ReduceSizeListItemsButton.Location = new System.Drawing.Point(12, 532);
            this.ReduceSizeListItemsButton.Name = "ReduceSizeListItemsButton";
            this.ReduceSizeListItemsButton.Size = new System.Drawing.Size(252, 43);
            this.ReduceSizeListItemsButton.TabIndex = 2;
            this.ReduceSizeListItemsButton.Text = "Reducing Result Size of List Items";
            this.toolTip1.SetToolTip(this.ReduceSizeListItemsButton, "Reduce Result Size of Lists");
            this.ReduceSizeListItemsButton.UseVisualStyleBackColor = false;
            this.ReduceSizeListItemsButton.Click += new System.EventHandler(this.ReduceSizeListItemsButton_Click);
            // 
            // UpdateButton
            // 
            this.UpdateButton.BackColor = System.Drawing.Color.White;
            this.UpdateButton.Location = new System.Drawing.Point(12, 384);
            this.UpdateButton.Name = "UpdateButton";
            this.UpdateButton.Size = new System.Drawing.Size(252, 43);
            this.UpdateButton.TabIndex = 4;
            this.UpdateButton.Text = "Update an Item";
            this.toolTip1.SetToolTip(this.UpdateButton, "Update an Item");
            this.UpdateButton.UseVisualStyleBackColor = false;
            this.UpdateButton.Click += new System.EventHandler(this.UpdateButton_Click);
            // 
            // CredentialsButton
            // 
            this.CredentialsButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
            this.CredentialsButton.Location = new System.Drawing.Point(12, 581);
            this.CredentialsButton.Name = "CredentialsButton";
            this.CredentialsButton.Size = new System.Drawing.Size(252, 43);
            this.CredentialsButton.TabIndex = 2;
            this.CredentialsButton.Text = "Credentials";
            this.toolTip1.SetToolTip(this.CredentialsButton, "Specify Credentials in Client Object Model");
            this.CredentialsButton.UseVisualStyleBackColor = false;
            this.CredentialsButton.Click += new System.EventHandler(this.CredentialsButton_Click);
            // 
            // MainForm
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(738, 690);
            this.Controls.Add(this.button4);
            this.Controls.Add(this.UpdateButton);
            this.Controls.Add(this.InsertButton);
            this.Controls.Add(this.datagrid);
            this.Controls.Add(this.GetByPageSizeButton);
            this.Controls.Add(this.CredentialsButton);
            this.Controls.Add(this.ReduceSizeListItemsButton);
            this.Controls.Add(this.ReduceResultSizeButton);
            this.Controls.Add(this.CriteriaButton);
            this.Controls.Add(this.UpdateTitleButton);
            this.Controls.Add(this.GetListDataButton);
            this.Controls.Add(this.ServerText);
            this.Controls.Add(this.ListInfoButton);
            this.Controls.Add(this.SiteInfoButton);
            this.Name = "MainForm";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Client Object Model - C# - Examples  (jeanpaulva.com)";
            ((System.ComponentModel.ISupportInitialize)(this.datagrid)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Button SiteInfoButton;
        private System.Windows.Forms.TextBox ServerText;
        private System.Windows.Forms.Button ListInfoButton;
        private System.Windows.Forms.Button GetListDataButton;
        private System.Windows.Forms.DataGridView datagrid;
        private System.Windows.Forms.Button UpdateTitleButton;
        private System.Windows.Forms.Button CriteriaButton;
        private System.Windows.Forms.Button GetByPageSizeButton;
        private System.Windows.Forms.Button InsertButton;
        private System.Windows.Forms.Button button4;
        private System.Windows.Forms.Button ReduceResultSizeButton;
        private System.Windows.Forms.Button ReduceSizeListItemsButton;
        private System.Windows.Forms.Button UpdateButton;
        private System.Windows.Forms.ToolTip toolTip1;
        private System.Windows.Forms.Button CredentialsButton;
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
United States United States
Jean Paul is a Microsoft MVP and Architect with 12+ years of experience. He is very much passionate in programming and his core skills are SharePoint, ASP.NET & C#.

In the academic side he do hold a BS in Computer Science & MBA. In the certification side he holds MCPD & MCTS spanning from .Net Fundamentals to SQL Server.

Most of the free time he will be doing technical activities like researching solutions, writing articles, resolving forum problems etc. He believes quality & satisfaction goes hand in hand.

You can find some of his work over here. He blogs at http://jeanpaulva.com

Comments and Discussions