【问题标题】:Sharepoint online office 365 list items created by asp.net form submit buttonSharepoint online office 365 列出由 asp.net 表单提交按钮创建的项目
【发布时间】:2014-05-15 11:20:43
【问题描述】:

我对 Office 365 上托管的 SharePoint Online 有疑问。

  1. 我有一个包含三个字段和一个提交按钮的 ASP.NET 表单。这些字段是:Namelastnamedisplay name
  2. 我在 SharePoint Online 网站上有一个具有相同字段的自定义列表:Namelastnamedisplay name

当用户填写表单并单击提交按钮时,我想将数据保存到 SharePoint 列表中。

我该怎么做?

【问题讨论】:

    标签: asp.net sharepoint office365 sharepoint-online


    【解决方案1】:

    您可以使用客户端对象模型更新 SharePoint Online 上的列表项:

    using(ClientContext clientContext = new ClientContext(siteUrl))
    {
     clientContext.Credentials = new SharePointOnlineCredentials(userName,password);
                    SP.List oList = clientContext.Web.Lists.GetByTitle("Announcements");
                    ListItem oListItem = oList.Items.GetById(3);
    
                    oListItem["Title"] = "My Updated Title.";
    
                    oListItem.Update();
    
                    clientContext.ExecuteQuery(); 
    }
    

    要创建新项目,请使用以下代码:

    List announcementsList = context.Web.Lists.GetByTitle("Announcements"); 
    
    // We are just creating a regular list item, so we don't need to 
    // set any properties. If we wanted to create a new folder, for 
    // example, we would have to set properties such as 
    // UnderlyingObjectType to FileSystemObjectType.Folder. 
    ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation(); 
    ListItem newItem = announcementsList.Items.Add(itemCreateInfo); 
    newItem["Title"] = "My New Item!"; 
    newItem["Body"] = "Hello World!"; 
    newItem.Update();  
    

    【讨论】:

    • 它在 context.web.lists 上给了我一个错误。我需要导入或“使用”什么来完成这项工作?
    猜你喜欢
    • 2013-06-03
    • 2015-03-07
    • 1970-01-01
    • 1970-01-01
    • 2015-12-25
    • 2020-10-20
    • 1970-01-01
    • 1970-01-01
    • 2019-01-08
    相关资源
    最近更新 更多