Try our conversational search powered by Generative AI!

PageList not showing programatically addded Pages


Helloh, I'm experiencing a somewhat odd problem. Have a page list and a button, the button adds a page programatically. And the pagelist is databound. But the Page list doesn't show the newly added page.



Codebehind (stripped down): 

protected override void OnLoad(System.EventArgs e)
if (!IsPostBack)
pl.PageLink = CurrentPage.PageLink;

protected void click(object sender, EventArgs e)
PageData a = EPiServer.DataFactory.Instance.GetDefaultPageData(CurrentPage.PageLink, 3, EPiServer.Security.AccessLevel.NoAccess);
a.PageName = DateTime.Now.ToLongTimeString();
EPiServer.DataFactory.Instance.Save(a, EPiServer.DataAccess.SaveAction.Publish, EPiServer.Security.AccessLevel.NoAccess);

//markup had to remove gt/lt because editor in forum acts weird.
  (asp:Content ContentPlaceHolderID="MainRegion" runat="server")
(EPiServer:PageList runat="server" ID="pl" )

(%# Container.CurrentPage.PageName %)



(asp:Button Text="add" OnClick="click" runat="server" /)










Jun 12, 2009 14:03
Try to set a.StartPublish = DateTime.Now.AddSeconds(-1);
Jun 12, 2009 14:59


I possible reason for this could be the start publish date. Since you don't set a start publish date DateTime.Now will be used as StartPublish date.

What that means is that the page will have a start publish that is basically the same as the time the request is made. And with a bit of (un)luck the page will be seen as not published and hence not visible for user with only read access to the page. We've made some improvents to handle this scenario better that will be included in SP2. It's a bit tricky though, since the date is saved and read from the database, and the database granuality isn't as good as ASP.NET:s, hence you can loose or gain one or two milliseconds on the date.

So, try adding a start publish time slightly in the past and see if it makes a difference.

a.StartPublish = DateTime.Now.AddMinutes(-1)


Per Gunsarfs
EPiServer CMS development team

Edited, Jun 12, 2009 15:02


it worked - thanks alot :)

Jun 18, 2009 14:36
* 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.