Get page ID of newly created page

Vote:
 

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);

#40659
Jun 15, 2010 10:33
Vote:
 

After you saved (created) the page you can access its id by

myPage.PageLink.ID

#40660
Jun 15, 2010 10:44
Vote:
 

Man, that's almost ridiculously easy. :)

Thanks!

#40664
Jun 15, 2010 11:07
Vote:
 

Also, the DataFactory.Save method returns a PageReference to the new page :)

#40671
Jun 15, 2010 11:57
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.