How do I get data from a specific page?

Vote:
 

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" />

</asp:Content>

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?

 

#33856
Oct 21, 2009 13:34
Vote:
 

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

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

Also: remember to databind your controls from codebehind.

#33857
Oct 21, 2009 13:53
Vote:
 

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?

 

 

#33858
Oct 21, 2009 14:07
Vote:
 

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 

#33859
Oct 21, 2009 14:17
Vote:
 

I REALLY don't like .NET anymore Tongue out 

 I found a workaround however: http://world.episerver.com/Forum/Pages/Thread.aspx?id=13276&epslanguage=en

 

 

#33861
Oct 21, 2009 14:28
Vote:
 
#33864
Oct 21, 2009 14:37
Vote:
 

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.

#33865
Oct 21, 2009 14:40
Vote:
 

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

#33866
Oct 21, 2009 14:42
Vote:
 

@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 :)

 

#33867
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.