Saturday, 21 July 2012

Create Webpart

Create dynamic webpart when create a page


 public void Createwebpart(string title)
        {
            Createdynamicpage(title);
            SPFile page = SPContext.Current.Web.GetFile("/Pages/" + title + ".aspx");
            using (SPLimitedWebPartManager wpmgr = page.GetLimitedWebPartManager(PersonalizationScope.Shared))
            {
                XmlElement p = new XmlDocument().CreateElement("p");
                p.InnerText = "Edit this webpart to add content on this Page";
                // page.DeleteProperty(pageLayouts[0]);

                ContentEditorWebPart cewp = new ContentEditorWebPart
                {
                    Content = p
                };
                wpmgr.AddWebPart(cewp, "Header", 0);
            }
            page.Update();
        }

No comments:

Post a Comment

SharePoint online - Get List-item attachments and Display to div

Step 1 : Create a List ex: TestList and attach few images Step 2 : Copy and Pastet the below coding in App.js var  Items =  null ; ...