var selectedItems = SP.ListOperation.Selection.getSelectedItems();
var ci2 = CountDictionary(selectedItems);
var ci2 = CountDictionary(selectedItems);
Exercise 1: Retrieving Lists
References--Microsoft.SharePoint.Client Micorosoft.SharePoint.Client.Runtime
C:\Program Files\Common Files\Microsoft Shared\web server
extensions\14\ISAPI
C#
1.
private void ShowButton_Click(object sender, EventArgs e)
2.
{
3.
//Show the hourglass wait cursor
4.
this.Cursor = Cursors.WaitCursor;
5.
ListsListBox.Items.Clear();
6.
//Get a context
7.
using (ClientOM.ClientContext ctx =
8.
new ClientOM.ClientContext(UrlTextBox.Text))
9.
{
10. //Get the site
11. ClientOM.Web site = ctx.Web;
12. ctx.Load(site);
13. //Get Lists
14. ctx.Load(site.Lists);
15. //Query
16. ctx.ExecuteQuery();
17. //Fill List
18. foreach (ClientOM.List list in site.Lists)
19. {
20. ListsListBox.Items.Add(list.Title);
21. }
22. //Return the cursor to normal
23. this.Cursor = Cursors.Default;
24. }
25. }
|
VB.NET
Private Sub ShowButton_Click(ByVal sender As Object, ByVal e
As EventArgs)
Handles
ShowButton.Click
'Show the
hourglass wait cursor
Me.Cursor =
Cursors.WaitCursor
ListsListBox.Items.Clear()
'Get a context
Using ctx As New
ClientOM.ClientContext(UrlTextBox.Text)
'Get the
site
Dim site As
ClientOM.Web = ctx.Web
ctx.Load(site)
'Get Lists
ctx.Load(site.Lists)
'Query
ctx.ExecuteQuery()
'Fill List
For Each list As ClientOM.List In
site.Lists
ListsListBox.Items.Add(list.Title)
Next
'Return the
cursor to normal
Me.Cursor =
Cursors.[Default]
End Using
End Sub
|
No comments:
Post a Comment