Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have to migrate some content from text files from my storage to my SharePoint 2013.

The plan is to put the content into some content editor webparts at a basic page.

I know how to create the basic pages like items in my doclib via a console app, but how do i get the CEWP for adding some content to it?

share|improve this question
add comment

1 Answer

The following code snippet could help you. This can be achieved using SPLimitedWebPartManager. Pass your required page url to "pageURL" in the code below.

SPLimitedWebPartManager mgr = web.GetLimitedWebPartManager(pageURL, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
             XmlElement p = new XmlDocument().CreateElement("p");
             p.InnerText = "<b>Hello World</b>";
             ContentEditorWebPart editor = new ContentEditorWebPart(){ Content = p};
             mgr.AddWebPart(editor, "Header", 1);
             spWebTest.Update();
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.