Exemplo n.º 1
0
        private void GenerateContentTypeList()
        {
            var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);

            using (var ctx = spContext.CreateUserClientContextForSPHost())
            {
                ContentTypeCollection contentTypes = ctx.Web.ContentTypes;
                ctx.Load(contentTypes);
                ctx.ExecuteQuery();

                drpContentTypes.DataTextField  = "Name";
                drpContentTypes.DataValueField = "StringId";
                drpContentTypes.DataSource     = contentTypes.OrderBy(ct => ct.Name);
                drpContentTypes.DataBind();
            }
        }
Exemplo n.º 2
0
        private void DoContentTypes(ContentTypeCollection contentTypes, BaseNode parentNode, BaseNode rootNode)
        {
            try
            {
                foreach (var contentType in contentTypes.OrderBy(c => c.Name))
                {
                    ContentTypeNode contentTypeNode = new ContentTypeNode(contentType);

                    parentNode.Children.Add(contentTypeNode);
                    contentTypeNode.ParentNode    = parentNode;
                    contentTypeNode.RootNode      = rootNode;
                    contentTypeNode.NodeConnector = this;
                }
            }
            catch (Exception ex)
            {
                // log
            }
        }