Sharepoint2010 对象模型(2)

2018-11-19 20:23

然后,我们把上一篇的代码复制过来,看看能不能工作

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 Microsoft.SharePoint.Client;

namespace SilverlightApplication3 { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); Loaded += new RoutedEventHandler(MainPage_Loaded); }

void MainPage_Loaded(object sender, RoutedEventArgs e) {

var url = \

using (ClientContext ctx = new ClientContext(url)) { //ctx.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials; Web web = ctx.Web; ctx.Load(web); ctx.Load(web.Lists); ctx.Load(web, w => w.Lists.Where(l => l.Title == \ ctx.ExecuteQuery();

List list = web.Lists[0]; CamlQuery camlQuery = new CamlQuery(); camlQuery.ViewXml = \ Name='Age' />60100\

ListItemCollection collListItem = list.GetItems(camlQuery);

ctx.Load(collListItem); ctx.ExecuteQuery();

var emps = collListItem.Select(i => new Employee() { FirstName = i[\ LastName = i[\ }); EmployeeList.ItemsSource = emps;

} } }

public class Employee { public string FirstName { get; set; } public string LastName { get; set; } } } 【注意】以上代码几乎和之前在Console里面一模一样

按下F5键运行,我们却收到了一个错误

查看原图(大图)

这其实是我们预见到的错误,之前我就说到过了,Silverlight程序所有的外部资源访问都要求是异步进行的。那就动手改一下吧

首先为了做得更加完善些,我们在布局方面做了一下小的调整添加了错误消息提示的功能


Sharepoint2010 对象模型(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2015-2016第二学期PS期中

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: