Tuesday, 17 March 2015

Sharepoint Objects

The best way to find out the properties of the Sharepoint objects is to use the reference pages on the web.



  1. Place the cursor on "SPSite" in the .cs file in Visual Studio:  Press "F1" key:  A browser page should open on the reference for SPSite:


  2. Google "SPSite" and choose the SPSite class item on MSDN







Note on the Class page the links to 

  • Members
  • Fields
  • Methods


Browsing the members, will show what functions or data members are available for each object, and allow you to find the class type for other SharePoint objects.



Overview of some principle SharePoint Objects

SPSite

SPSite represents a SharePoint site and is usually the way into the SharePoint system (see examples), having said that we usually don't do much with it other than to access the SPWeb that contains the data in the site.
SPSite should be closed and disposed when finished with, so should be accessed through a using(){} block.

We can access the SPWeb object from the SPSite through the OpenWeb() function.


SPWeb

The SPWeb is one of the most useful objects as it contains the lists, the user info etc.  SPWEb should be closed and disposed when finished with so it best accessed through a using( ) {} block.


  • CurrentUser gets information about the current user
  • Lists is a collection that holds all the lists in the web / site (SPList)



SPList

SPList objects represent lists on the site.

  • Items contains the rows (items) in the list
  • Fields is a collection of SPField objects that define the columns/fields in the list
  • Views is a collection of objects representing the views defined for the list

SPListItem

SPListItem represents the items in the SPList (see examples).  Note that there are two possible objects that can be used from a SPList.Items collection:  SPItem and SPListItem.  The List Item is the better class to use as it has member specific to the list.

SPUser

SPUser represents sharepoint users,and is used when want information about users, or to read or modify details of who last edited an object etc.

No comments:

Post a Comment