Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Animation;
- using System.Windows.Shapes;
- using ClientOM = Microsoft.SharePoint.Client;
- using Microsoft.SharePoint.Client;
- namespace SLCSTest
- {
- public partial class MainPage : UserControl
- {
- Web oWebsite;
- ListCollection collList;
- IEnumerable<List> listInfo;
- public MainPage()
- {
- InitializeComponent();
- }
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- ClientContext clientContext = ClientContext.Current;
- oWebsite = clientContext.Web;
- ListCollection collList = oWebsite.Lists;
- clientContext.Load(oWebsite,
- website => website.Title);
- listInfo = clientContext.LoadQuery(
- collList.Include(
- list => list.Title,
- list => list.Fields.Include(
- field => field.Title).Where(
- field => field.Required == true
- && field.Hidden != true)));
- clientContext.ExecuteQueryAsync(onQuerySucceeded, onQueryFailed);
- }
- private void onQuerySucceeded(object sender, ClientRequestSucceededEventArgs args)
- {
- UpdateUIMethod updateUI = DisplayInfo;
- this.Dispatcher.BeginInvoke(updateUI);
- }
- private void onQueryFailed(object sender, ClientRequestFailedEventArgs args)
- {
- btnButton.Content = "Request failed. " + args.Message + "\n" + args.StackTrace;
- }
- private void DisplayInfo()
- {
- btnButton.Content = "Title: " + oWebsite.Title;
- collList = oWebsite.Lists;
- foreach (List oList in listInfo)
- {
- btnButton.Content += "\n\tList: " + oList.Title;
- FieldCollection collField = oList.Fields;
- foreach (Field oField in collField)
- {
- btnButton.Content += "\n\t\tField: " + oField.Title;
- }
- }
- }
- private delegate void UpdateUIMethod();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment