SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I have the standard Content Editor Webpart (MSContentEditor.dwp). The title i can set via webPart.Title (MSDN).

I can't find any property where I would set the content editor's content.

I basically want to provision the webpart to a publishing page (done), set it's title so something (done) and set some default content for it (stuck on this one). Any help is appreciated.

share|improve this question
up vote 2 down vote accepted
ContentEditorWebPart wp = ....

XmlDocument xDoc = new XmlDocument();
var contentRoot = xDoc.CreateElement("ContentRoot");
contentRoot.InnerText = "Your text here";
wp.Content = contentRoot

share|improve this answer
That was easy :-) – Dennis G May 25 '11 at 9:22

Here you go :)

ContentEditorWebPart.Content Property

You might need to cast your WebPart to ContentEditorWebPart if you can't see this property.

share|improve this answer

Your Answer


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.