Sharepoint2013 Object Model

Source: Internet
Author: User
Introduction to object models in SharePoint

The hierarchical structure of objects in Sharepoint is

Webapplication-> spsite-> spweb-> splist-> spitem. That is to say, the webapp has the largest application, including the website set spsite, the website set includes the website Web, and the list splist is down, and the list items include spitem.

Some operations on a Sharepoint object.

1. website set

Server code:

All website sets under the Application

Foreach (spsite inspcontext. Current. Site. webapplication. Sites) {// All website sets under the application program}

Website set under the current site

<span style="font-size:18px;">SPSite spSite = SPContext.Current.Site;</span>

2 websites

Root website under the website set

<span style="font-size:18px;">SPWeb spWeb =spSite.RootWeb;</span>

Websites used in the website set

<Span style = "font-size: 18px;"> foreach (spweb spsite in spsite) {// All website sets under the application program} </span>
3. List

List object (a list of variable types is required many times). The document library type is 101.

<Span style = "font-size: 18px;"> foreach (splist in spweb. lists) {If (INT) splist. basetemplate = 101) {// traverse the list of all document library classes }}</span>
4. Fields

Read the information of fields in each row.

Here is an example: who created this field by creating a new ribbon and using Js in it.

<span style="font-size:18px;">    var userAdress;                var userName;                var id = GetItemID();                function GetItemID() {                          var selectedItems =SP.ListOperation.Selection.getSelectedItems();                          var count =CountDictionary(selectedItems);                          if (count > 0) {                              returnselectedItems[0].id;                          } else {                              return null;                          }                      }                              functionOnQuerySucceeded(sender, args) {                         this.userAdress=listItem.get_item('Created_x0020_By');                         this.userName=listItem.get_item('Author').$2e_1;                         alert(this.userAdress+' '+this.userName)                      }                function OnQueryFailed() {                }                if (id != null) {                    context =SP.ClientContext.get_current();                    var listId =SP.ListOperation.Selection.getSelectedList();                    var corporateCatalog =context.get_web().get_lists().getById(listId);                    listItem =corporateCatalog.getItemById(id);                    context.load(listItem);                   context.executeQueryAsync(OnQuerySucceeded, OnQueryFailed);                }</span>


Summary:

These applications are examples of practical applications developed by the author, hoping to help you. I hope to realize my technical confidant. I am a self-scholar who loves computer programming.

Sharepoint2013 Object Model

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.