通過以下標準代碼,我花了很多時間在Silverlight訪問Sharepoint 2010問題上,但onQueryFailed方法始終被打中。請幫忙,謝謝!通過Silverlight無法使用客戶端對象模型將項目添加到Sharepoint列表
ClientContext clientContext = new ClientContext(siteUrl);
Web oWebsite = clientContext.Web;
ListCollection collList = oWebsite.Lists;
oList = clientContext.Web.Lists.GetByTitle("ClientList");
ListItem oListItem = oList.AddItem(new ListItemCreationInformation());
oListItem["Name"] = "John Doe";
oListItem["Address"] = "123 main rd.";
oListItem.Update();
clientContext.Load(oList,list => list.Title);
clientContext.ExecuteQueryAsync(onQuerySucceeded, onQueryFailed);
}
private void onQuerySucceeded(object sender, ClientRequestSucceededEventArgs args)
{
UpdateUIMethod updateUI = DisplayInfo;
this.Dispatcher.BeginInvoke(updateUI);
}
private void DisplayInfo()
{
MyOutput.Text = "New item created in " + oList.Title;
}
private void onQueryFailed(object sender, ClientRequestSucceededEventArgs args)
{
MessageBox.Show("Failed");
}
感謝阿方索!但不是原因:我將「標題」更名爲「名稱」,「標題」實際上是我的「名稱」。 – Mike