Skip to content
Loading
  • 0

    Thank you... I was able to resolve it.

     The working code is:

    using (ClientContext ctx = new ClientContext(siteUrl))
    {
    if (siteUrl.ToLower().Contains(_SiteFormat)) ctx.Credentials = new SharePointOnlineCredentials(userName, pwd);
    else ctx.Credentials = new System.Net.NetworkCredential(userName, pwdS);
    Web web = ctx.Web;
    ListCollection listColl = web.Lists;
    //List Creation
    ListCreationInformation LCinfo = new ListCreationInformation();
    LCinfo.Title = ListName;
    LCinfo.TemplateType = (int)ListTemplateType.GenericList;
    LCinfo.Description = "First Dynamic List";
    listColl.Add(LCinfo);
    ctx.Load(listColl);
    ctx.ExecuteQuery();
    // Column creatton
    List tList = web.Lists.GetByTitle(ListName);
    Field tField = tList.Fields.AddFieldAsXml("", true, AddFieldOptions.DefaultValue);
    Field dField = tList.Fields.AddFieldAsXml("", true, AddFieldOptions.DefaultValue);
    tList.Update();
    ctx.ExecuteQuery();
    } 
    0