SharePoint發行版本有SharePoint2003、SharePoint2007、Sharepoint 2010、SharePoint2013和SharePoint2016。SharePoint提供了功能強大的團隊協作環境,使得組織能夠在整個組織內部實現整合、組織、查找和提供 SharePoint站點。 1、創建Silverlight時,選擇Silverlight 4,不要選擇版本5,試了很久版本5都調用不了,自己也不知道什么原因,谷歌也沒找到答案,后來嘗試版本4,可以調用; 至于Host the Silverlight application是否勾選沒有影響; 2、Silverlight中使用客戶端腳本,和Net中不一樣,要添加下面兩個引用; 3、兩個需要的引用,在服務器上位置為C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\LAYOUTS\ClientBin,如下圖: 4、然后在Silverlight的cs文件中添加引用,如下: using Microsoft.SharePoint.Client; 然后添加讀取List的代碼,如下: ![]() public string url = "http://server:80";Web web;List list;ListItemCollection itemColl;string listName = "Silverlight";string camlStr = "";private void btn_ShowMessage_Click(object sender, RoutedEventArgs e){ getdata();}public void getdata(){ try { ClientContext context = new ClientContext(url); web = context.Web; list = web.Lists.GetByTitle(listName); CamlQuery query = new CamlQuery(); query.ViewXml = camlStr; itemColl = list.GetItems(query); context.Load(itemColl); context.ExecuteQueryAsync(new ClientRequestSucceededEventHandler(OnSuccessed), new ClientRequestFailedEventHandler(OnFailed)); } catch (Exception ex) { MessageBox.Show(ex.Message); }}private void OnSuccessed(Object sender, ClientRequestSucceededEventArgs args){ this.Dispatcher.BeginInvoke(LoadData);}private void LoadData(){ String data = string.Empty; foreach (ListItem item in itemColl) { data += item["Title"].ToString() + "\r\n"; } lb_Message.Content = data;}private void OnFailed(Object sender, ClientRequestFailedEventArgs args){ this.Dispatcher.BeginInvoke(delegate() { MessageBox.Show("Get Data Failed"); });} ![]() 5、前臺頁面添加Silverlight展示WebPart,添加完畢如下圖: 6、點擊ShowMessage,執行客戶端對象模型的方法,結果如下圖: 總 結 自己對于Silverlight不是很熟悉,只是小有了解SharePoint,所以有問題之處還請大家指正。嘗試了很多次,才發現如何能在Silverlight中使用SharePoint客戶端對象模型,希望分享給有需要的人,給大家一個參考吧。 好了,就到這里,休息。。休息一下。。 Sharepoint 可以幫助企業用戶輕松完成日常工作。 |
溫馨提示:喜歡本站的話,請收藏一下本站!