Sitefinity CMS

Creating Comments Send comments on this topic.
See Also
Developing with Sitefinity > Modules > Modules API > Generic Content > Comments > Creating Comments

Glossary Item Box

Following is an example of how to create a comment item:

Create new comment item by passing the parent content item:

CreateComment(IContent item) Copy Code
// create new instance of ContentManager
Telerik.Cms.Engine.ContentManager contentManager = new Telerik.Cms.Engine.ContentManager();
// get all content items
IList listOfContentItems = contentManager.GetContent();
if (listOfContentItems.Count > 0)
{
   
// get the first content item
   
Telerik.Cms.Engine.IContent firstContent =  contentManager.GetContent(((Telerik.Cms.Engine.IContent)listOfContentItems[0]).ID);
   
// create a comment for the content item firstContent
   
Telerik.Cms.Engine.IComment firstComment = contentManager.CreateComment(firstContent);
   
// save value for Text property
   
firstComment.Text = "my comment";
   
// save the comment in the database
   
contentManager.SaveComment(firstComment);
   Response.Write(firstComment.Text +
"<br />");
   Response.Write(firstComment.Parent.GetMetaData(
"Name") + "<br />");
}

 

See Also