SharePoint 2013 - SPLessons

Chapter 32

SharePoint Managed code

SharePoint Managed code

The managed client object, you can do all the SharePoint website related tasks such as read and write all the website related properties, create a new SharePoint web site, SharePoint List operations (create new SharePoint lists, retrieve all SharePoint lists in a SharePoint website, insert, update and delete in SharePoint lists), SharePoint Document Library operations (the same as SharePoint List operations).

the development in the managed client object model. You will need to add references for the Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.ClientRuntime.dll into the assemblies and add the using statement for the Microsoft.SharePoint.Client namespace and start writing the code.

Adding the item into the Sharepoint list

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;

namespace ClientObjectModel
    class Program
        static void Main(string[] args)
      		using (ClientContext context = new ClientContext("http://splessons:5151/"))
                    Web spWeb = context.Web;
                    context.Credentials = credentials;
                    List oList  = spWeb.Lists.GetByTitle("Splessons");

                    ListItemCreationInformation listCreationInformation = new ListItemCreationInformation();
                    ListItem oListItem  = oList.AddItem(listCreationInformation );                    

                    //inserts  values
                    oListItem ["First_x0020_Name"] = "Sreehari";
                    oListItem ["Last_x0020_Name"] = "Inukollu";

                    oListItem .Update();