aneeshsiva-gmail
-
5/16/2011 8:55:37 AM
How to create a document in cms desk via aspx code
I need to create a new document in cms desk via code I tried the following method
But I cant see the created document in the cms desk (I dont know whether the document is created or not). Is there is anything more to do with my existing code.
//Create the instance for the TreeProvider class CMS.TreeEngine.TreeProvider provider = new CMS.TreeEngine.TreeProvider(CMS. CMSHelper.CMSContext.CurrentUser); //Get the Parent node for the new document CMS.TreeEngine.TreeNode parent = provider.SelectSingleNode(CMS.CMSHelper. CMSContext.CurrentSiteName, "/MyNews", "en-us"); //Create a new Tree node at the specified CMS.TreeEngine.TreeNode node = new TreeNode("cms.news", provider); if (parent != null) { //Now set the properties for the document if the parent node found node.NodeName = "MyFirstNews"; node.NodeAlias = "MyFirstNews"; node.SetValue("DocumentCulture", "en-us"); node.SetValue("NewsTitle", "MyFirstNewsTitle"); node.SetValue("NewsSummary", "My First News Summary."); node.SetValue("NewsText", "My First News Text."); node.SetValue("NewsReleaseDate", DateTime.Now); //Now insert the document at the proper place New document node.Insert(parent.NodeID); }
Regards: Aneesh Sivan
|