Sitefinity CMS

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

Glossary Item Box

The following examples demonstrate how to create a new category:

Create a category:

CreateCategory() Copy Code
// create new instance of ContentManager
Telerik.Cms.Engine.ContentManager contentManager = new Telerik.Cms.Engine.ContentManager();
// create a new category
Telerik.Cms.Engine.ICategory firstCategory = contentManager.CreateCategory();
// save CategoryName value
firstCategory.CategoryName = "Category 1";
// save category object to database
contentManager.SaveCategory(firstCategory);
Response.Write(firstCategory.CategoryName +
"<br />");

 

Create a category with specified name:

CreateCategory(string categoryName) Copy Code
// create new instance of ContentManager
Telerik.Cms.Engine.ContentManager contentManager = new Telerik.Cms.Engine.ContentManager();
// create a new category
Telerik.Cms.Engine.ICategory firstCategory = contentManager.CreateCategory("Category 2");
// save category object to database
contentManager.SaveCategory(firstCategory);
Response.Write(firstCategory.CategoryName +
"<br />");  

 

See Also