Try our conversational search powered by Generative AI!

Retrive properties from page in newslist

Vote:
 
I am working with the NewsListControl webcontrol. In the newstemplate I sometimes want to be able to show a thumbnail next to the news listed. I am trying to solve this by calling a method from the newstemplate: <%#getintroimagetag() %>
#12211
Feb 09, 2005 13:11
Vote:
 
(accidently pushed the publish button, here comes the rest ;) ) For each iterated news this method is called. But in the method I would like to use the CurrentPage property of the NewsListControl to retrieve propertys like introImage. But CurrentPage only returns the page containing the NewsListControl every time, I do not get the news items. Does anybody know how to retrieve the currently iterated page from the code behind? I am thinking about sending it as an argument to the method, i.e: <%#GetIntroImageTag(Container.CurrentPage.PageLink.ID) %> But I guess there should be a easier way to do it. Any clues? Thank you.
#13841
Feb 09, 2005 13:21
Vote:
 
Hello! You could either send Container.CurrentPage to a method <%#GetIntroImageTag(Container.CurrentPage) %> use a EPiServer.WebControls.Property or just access the PropertyCollection directly <%#Container.CurrentPage["YourPropertyName"]%>
#13842
Feb 09, 2005 14:33
Vote:
 
If you use ]]> dont forget the type for CurrentPage will be PageData... protected string GetIntroImageTag(PageData cp) just in case it wasnt obvious...
#13843
Feb 09, 2005 14:58
Vote:
 
Thank you for your answers! I ended up using GetIntroImageTag(Container.CurrentPage.PageLink) Good to know that there is no other possibility to reach the "current news" from the codebehind.
#13844
Feb 10, 2005 10:02
Vote:
 
Not having seen the code behind the GetIntroImageTag(...), you'd probably be better off sending Container.CurrentPage instead of the Container.CurrentPage.PageLink. Especially if you do GetPage(pageLink) in you method. There is no other way to get to the current item, unless you want to walk the control tree. The Repeater control in asp.net has an ItemDataBound event, that occurs for each item in the list, after it has been databound, but before the itemtemplate is rendered. PageList (Newslist etc.) does not have this event, and in my opinion, using the event to change or format content in the ItemTemplate container is not an elegant way to write code. /Steve
#13845
Feb 10, 2005 11:52
* 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.