ClientContext clientContext = new ClientContext(siteUrl);
Web oWebsite = clientContext.Web;
ListCollection collList = oWebsite.Lists;
oList = clientContext.Web.Lists.GetByTitle("yourList");
ListItem oListItem = oList.AddItem(new ListItemCreationInformation());
oListItem["Title"] = "My new item";
oListItem["Body"] = "This is my new item.";
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;
}
Ads by Google
No comments:
Post a Comment