use*_*851 2 sharepoint content-type sharepoint-clientobject
我创建了一个SP.List项"lst".我也:
lst.ContentTypesEnabled = true;
lst.Update();
clientContext.ExecuteQuery();
Run Code Online (Sandbox Code Playgroud)
我搜索了AvailableContentTypes并找到了我要添加到lst的那个.然后我:
SP.ContentTypeCollection lstTypeCollection = lst.ContentTypes;
Run Code Online (Sandbox Code Playgroud)
......现在我被卡住了.
我lstTypeCollection.Add()想要一个ContentTypeCreationInformation物体,我在黑暗中徘徊.
你能摆脱光明吗?提前致谢 :-)
使用ContentTypeCollection.AddExistingContentType方法将现有内容类型添加到列表中.
var list = context.Web.Lists.GetByTitle(listTitle);
list.ContentTypesEnabled = true;
var contentType = context.Site.RootWeb.ContentTypes.GetById("0x0120"); //get Folder content type
list.ContentTypes.AddExistingContentType(contentType);
context.ExecuteQuery();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4057 次 |
| 最近记录: |