ContentEditorWebPart.Content property

Gets or sets embedded HTML that provides content for this Web Part.

Namespace:  Microsoft.SharePoint.WebPartPages
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
<MultilingualAttribute> _
<ResourcesAttribute("", "Advanced", "Content")> _
<WebPartStorageAttribute(Storage.Shared)> _
Public Property Content As XmlElement
    Get
    Set
'Usage
Dim instance As ContentEditorWebPart
Dim value As XmlElement

value = instance.Content

instance.Content = value
[MultilingualAttribute]
[ResourcesAttribute("", "Advanced", "Content")]
[WebPartStorageAttribute(Storage.Shared)]
public XmlElement Content { get; set; }

Property value

Type: System.Xml.XmlElement
String Embedded HTML.

Remarks

The Content property is read/write. Embedded content is stored as a string value in the database. There is no maximum length for this string, and there is no default value. Because the Content property contains the body of the Web Part, content can consist of any Web-based material.

This property is optional, since content can also be provided using the ContentLink property. To provide content, however, at least one of these two methods must be used. The Web Part Page checks the ContentLink first and uses that if it is specified.

The Content property can contain embedded content or provide error text that this Web Part should display if ContentLink fails. For example, depending on your Web Part Page implementation, the Content property can be used to respond to users who attempt to reach online content without an Internet or intranet connection.

The Storage type of the Content property is Storage.Shared.

Examples

The following code example creates a new Content Editor Web Part and adds content by setting the Content property.

' Create a new Content Editor Web Part.
Private ceWebPart As New ContentEditorWebPart()

' Create an XmlElement to hold the value of the Content property.
Private xmlDoc As New XmlDocument()
Private xmlElement As XmlElement = xmlDoc.CreateElement("MyElement")
xmlElement.InnerText = "My Sample Content" 

' Set the Content property to the XmlElement.
ceWebPart.Content = xmlElement
// Create a new Content Editor Web Part.
ContentEditorWebPart ceWebPart = new ContentEditorWebPart();

// Create an XmlElement to hold the value of the Content property.
XmlDocument xmlDoc = new XmlDocument();
XmlElement xmlElement = xmlDoc.CreateElement("MyElement");
xmlElement.InnerText = "My Sample Content";

// Set the Content property to the XmlElement.
ceWebPart.Content = xmlElement;

See also

Reference

ContentEditorWebPart class

ContentEditorWebPart members

Microsoft.SharePoint.WebPartPages namespace