protected void InsertItem()
{
try
{
SecureString Password = new SecureString();
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
foreach (char c in "password")
{
Password.AppendChar(c);
}
ClientContext clientcontext = new ClientContext(url);//"https://orgname.sharepoint.com/sites/MainListSite"
clientcontext.Credentials = new SharePointOnlineCredentials(username, Password);
List olist = clientcontext.Web.Lists.GetByTitle("FirstMainList");
ListItemCreationInformation listiteminfor = new ListItemCreationInformation();
Microsoft.SharePoint.Client.ListItem olistitem = olist.AddItem(listiteminfor);
olistitem["Title"] = "1";
olistitem.Update();
clientcontext.ExecuteQuery();
}
catch(Exception ex)
{
Label1.Text = ex.Message;
}
}
{
try
{
SecureString Password = new SecureString();
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
foreach (char c in "password")
{
Password.AppendChar(c);
}
ClientContext clientcontext = new ClientContext(url);//"https://orgname.sharepoint.com/sites/MainListSite"
clientcontext.Credentials = new SharePointOnlineCredentials(username, Password);
List olist = clientcontext.Web.Lists.GetByTitle("FirstMainList");
ListItemCreationInformation listiteminfor = new ListItemCreationInformation();
Microsoft.SharePoint.Client.ListItem olistitem = olist.AddItem(listiteminfor);
olistitem["Title"] = "1";
olistitem.Update();
clientcontext.ExecuteQuery();
}
catch(Exception ex)
{
Label1.Text = ex.Message;
}
}
No comments:
Post a Comment