Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

How do I get data from a specific page?


First: I'm stuck with EPi 4.61 :(

I need to display data from a specific page. In my template I have a PageReference property, which I use to link up to the page I need to get info from.

This code works:

<asp:Content ID="rightColumnRegion" ContentPlaceHolderID="rightColumnRegion" runat="server">

<h2 class="defaultGreen"><EPiServer:Property ID="Property1" PageLink="3212" PropertyName="PageName" runat="server" /></h2>

<div class="spacer10px"></div>

<p><EPiServer:Property ID="Property2" PageLink="3212" PropertyName="MainIntro" runat="server" /></p>

<EPiServer:Property ID="Property3" PageLink="3212" PropertyName="PageLink" runat="server" />


The problem is when I try to replace '3212' with my page property. The following does not work:

PageLink="<%= CurrentPage["myProperty"]" %>


So how can I do this?


Oct 21, 2009 13:34

Using <%= will only work for string values, you need to use #:

PageLink="<%# CurrentPage["myProperty"] %>

Also: remember to databind your controls from codebehind.

Oct 21, 2009 13:53

aaah... I did not bind each EPiServer:Property.
Basic, I know. But been away from EPiCode a long time :) 

But I'm not able to find my Property1 controller in Page_Load.
Do I have to do a FindControll on PageRender or something?



Oct 21, 2009 14:07

Well this is more .net than EPiServer related.

If you add a webcontrol to your .aspx file the .aspx.cs.designer file should be updated with a reference to your added control, thereby making Property1 available as an object in your codebehind. So no, not necessary to use FindControl. 

If your .designer file isn't updated, google will help you. Smile 

Oct 21, 2009 14:17

I REALLY don't like .NET anymore Tongue out 

 I found a workaround however:



Oct 21, 2009 14:28
Oct 21, 2009 14:37

What is wrong with the following? No databinding required.

<EPiServer:Property runat="server" PageLinkProperty="myProperty" PropertyName="MainIntro" />

Where myProperty is a PageReference property on the current page and MainIntro is a property on the page myProperty points to.

Oct 21, 2009 14:40

Nothing wrong with it, just explaining why his example failed. You're right, using PageLinkProperty is better.Smile

Oct 21, 2009 14:42

@Frederik Thanks. That worked perfectly.

I had tried that. But what I did wrong, was this: PageLinkProperty="<%= CurrentPage["myProperty"] %>" 

But now that I understand how  PageLinkProperty works, it's all sweet :)


Oct 21, 2009 14:47
* 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.