IT tutorials
 
Technology
 

Sharepoint 2013 : Overview of The Client-Side Object Model and Rest APIs - WINDOWS PHONE (part 2) - Querying

4/25/2014 3:44:37 AM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

Querying

The only major difference between the Windows Phone CSOM and the Managed CSOM that you will not be familiar with from previous releases is in how you set up authentication. This step is required prior to making any CSOM calls. To do it you first pick the authentication option that your SharePoint site uses. You create a ClientContext object and then set up the Credentials property on it. In the following example the Credentials property is set to authenticate using Office 365:

ClientContext context = new ClientContext("https://contoso.sharepoint.com/");
Authenticator auth = new Authenticator();

auth.AuthenticationMode = ClientAuthenticationMode.MicrosoftOnline;
context.Credentials = auth;

NOTE The Windows Phone CSOM library assists your authenticating with SharePoint Online by opening a Sign In window that allows the user to sign in to the SharePoint site, as shown in Figure 2. Providing a username and password and circumventing this user interaction are not possible at this time.

FIGURE 2

image

Alternatively, if your SharePoint Server uses forms authentication, then you can supply a username and password as follows:

auth.AuthenticationMode = ClientAuthenticationMode.FormsAuthentication;

auth.UserName = "Your_UserName";
auth.Password = "Password";

After you indicate your authentication options you are ready to start making CSOM calls to SharePoint. The code is almost the same as what you would use with the JavaScript or Managed CSOM; however, because Windows Phone Silverlight requires all network calls to be made asynchronously, you must cater callbacks in that manner for when your CSOM call succeeds or fails. To illustrate this process the following code makes a CSOM call to retrieve a list from the SharePoint Server:

List list = context.Web.Lists.GetByTitle("My Custom List");

// Load the query and execute the request to fetch data.
context.Load(list);

context.ExecuteQueryAsync((object obj, ClientRequestSucceededEventArgs args) =>
{
// success
var SiteId = list.Id;
},
(object obj, ClientRequestFailedEventArgs args) =>
{
// query failed.
});

As you can see the code defines a success and a failure function inline using a lambda expression. In your success function you can query and use the now “full” objects you asked for in your CSOM query.

The Windows Phone Silverlight Client-Side Object Model provides a great set of functionality to quickly get you up and running querying and interacting with SharePoint. You must take into account some differences with authentication and some runtime subtleties such as asynchronous callbacks. However, for the most part you can use the CSOM the same way you use the Managed CSOM.

 
Others
 
- Sharepoint 2013 : Overview of The Client-Side Object Model and Rest APIs - WINDOWS PHONE (part 1) - Setup
- Sharepoint 2013 : Overview of The Client-Side Object Model and Rest APIs - JAVASCRIPT (part 3) - Using the JavaScript Client-Side Object Model in a SharePoint-Hosted App Using Napa for Office 365
- Sharepoint 2013 : Overview of The Client-Side Object Model and Rest APIs - JAVASCRIPT (part 2) - Querying
- Sharepoint 2013 : Overview of The Client-Side Object Model and Rest APIs - JAVASCRIPT (part 1) - Setup
- Active Directory 2008 Optimization and Reliability : Monitoring and Troubleshooting Active Directory Components (part 4) - The Event Viewer
- Active Directory 2008 Optimization and Reliability : Monitoring and Troubleshooting Active Directory Components (part 3) - The Network Monitor, The Task Manager
- Active Directory 2008 Optimization and Reliability : Monitoring and Troubleshooting Active Directory Components (part 2) - Monitoring Active Directory Performance with Performance Monitor
- Active Directory 2008 Optimization and Reliability : Monitoring and Troubleshooting Active Directory Components (part 1) - Monitoring Domain Controller Performance
- Sharepoint 2013 : Overview of The Client-Side Object Model and Rest APIs - MANAGED CODE (.NET)
- Sharepoint 2013 : Overview of The Client-Side Object Model and Rest APIs - CLIENT-SIDE OBJECT MODEL (CSOM) BASICS
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us