Access SharePoint Data Production site news list with client model

Source: Internet
Author: User

Accessing SharePoint data with the client model

When accessing SharePoint data with the client model, you first add two references, one is Microsoft.SharePoint.Client, and the other is Microsoft.SharePoint.Client.Runtime

In the program to reference the Microsoft.SharePoint.Client namespace

1. Here is a simple example of accessing SharePoint list data, reading the list name as a news list, where

ClientContext ct = new ClientContext ("http://moss:84");
networkcredential NW = credentialcache.defaultnetworkcredentials;
Ct. Credentials = NW;
Microsoft.SharePoint.Client.Web Web = Ct. Web;

List LST = web. Lists.getbytitle ("News list");
Camlquery camlquery = new Camlquery ();
Camlquery.viewxml = "<View/>";
Microsoft.SharePoint.Client.ListItemCollection lts = lst. GetItems (Camlquery);
Fieldcollection FLDS = lst. fields;
Ct. Load (LST);
Ct. Load (LTS);
Ct. Load (FLDS);
Ct. ExecuteQuery ();

String fName = String. Empty;
foreach (Field f in FLDS)
//{
if (F.title = = "pinned image")
// {
FName = F.internalname;
Break
// }
//}
Here is the value of the Read Spfieldurlvalue field whose value contains two values, one is the URL, and the other is the description
foreach (Microsoft.SharePoint.Client.ListItem lt in Lts)
//{
if (lt[fname]!=null)
//{
Fieldurlvalue FURL = new Fieldurlvalue ();
FURL = (fieldurlvalue) lt[fname];
Response.Write ("ID:" +i.tostring () + ", LID:" +lt. Id+ "," +furl.url);
Response.Write ("<br/>");
i++;
//}
Response.Write (Lt[fname]);
Response.Write ("<br/>");
// }
Microsoft.SharePoint.Client.ListItem lt = lts[0];
foreach (Microsoft.SharePoint.Client.Field f in FLDS)
{
Response.Write ("Field Name:" +f.title+ ": Field Intername:" +f.internalname);
Response.Write ("<br/>");
}

Access SharePoint Data Production site news list with client 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.