London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Create new pages from code

Vote:
0
Is there a best practice available for how to create pages in EPiServer CMS 5 programatically?
#15863
Nov 08, 2007 11:47
Vote:
0
I dont know, but I do like this in EpiServer 5, and it works fine ! int intRefId = 123; // id to parent PageReference prParent = new PageReference(intRefId); PageData pdNewEpiPage = null; pdNewEpiPage = EPiServer.DataFactory.Instance.GetDefaultPageData(prParent, "MyPageTypeName", EPiServer.Security.AccessLevel.NoAccess); pdNewEpiPage.PageName = "My Instance Name"; pdNewEpiPage.SetValue("Prop1", "My Prop1 Value"); pdNewEpiPage.SetValue("Prop2", "My Prop2 Value"); PageReference prNewEpiPage = EPiServer.DataFactory.Instance.Save(pdNewEpiPage, EPiServer.DataAccess.SaveAction.Publish, EPiServer.Security.AccessLevel.NoAccess); int intNewId = prNewEpiPage.ID; // Done ! Maybe this is not what you asked, please comment if so !
#16520
Nov 08, 2007 21:23
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.