search
AI OnAI Off
A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More.
After you saved (created) the page you can access its id by
myPage.PageLink.ID
Also, the DataFactory.Save method returns a PageReference to the new page :)
I'm creating pages in code behind and would like to fetch and store the page id of the page that was just created. How can this be done? Here's the code used to create the page.
ProfileBase userProfile = ProfileBase.Create(Page.User.Identity.Name);
PageReference parent = CurrentPage["TeamBlogStart"] as PageReference;
PageData myPage = EPiServer.DataFactory.Instance.GetDefaultPageData(parent, "Blog personal start");
myPage.PageName = blogName;
myPage.URLSegment = EPiServer.Web.UrlSegment.CreateUrlSegment(myPage);
DataFactory.Instance.Save(myPage, SaveAction.Publish, AccessLevel.NoAccess);