3

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.

2 Answers 2

4
ContentEditorWebPart wp = ....

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

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.contenteditorwebpart.content.aspx

1
  • That was easy :-)
    – Dennis G
    Commented May 25, 2011 at 9:22
1

Here you go :)

ContentEditorWebPart.Content Property

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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