开发者

using EPiImageResizer in a Repeater

I'm not getting EPiImage to show me the image when I use it in a Repeater.

If I move the resizer outside of the Repeater it works like a charm..

Is there anything sp开发者_开发技巧ecial I need to think about?

<asp:Repeater ID="PageMenu" runat="server">
    <HeaderTemplate>
        <nav id="InlineSubNav">
            <ul>
    </HeaderTemplate>
    <ItemTemplate>
        <EPiImage:EPiImageResizer PropertyName="Image" Width="150" Height="150" Transformation="ScaleToFill" runat="server" />
        <EPiServer:Property PropertyName="MainIntro" runat="server" />
        <EPiServer:Property PropertyName="PageLink" runat="server" />
    </ItemTemplate>
    <FooterTemplate>
            </ul>
        </nav>
    </FooterTemplate>
</asp:Repeater>


According to the source code for EPIImageResizer, the Render method will pick the property from another page, providing that the PageLink is set:

    //If PageLink is set use that page instead of the current page
    if (PageLink != PageReference.EmptyReference)
      PageDataToUse = DataFactory.Instance.GetPage(PageLink);

    if (PageDataToUse[PropertyName] != null)
    {
      ImageUrl = PageDataToUse[PropertyName].ToString();

So providing you are setting the PageLink property correctly, then there shouldn't be a problem.

Try using the binding syntax to populate the PageLink property within the ItemTemplate on the repeater, using something like this:

    PageLink="<%# ((PageData)Container.DataItem).PageLink %>"

Alternatively set the value in the code behind by subscribing to the repeater's ItemDataBound event, retrieve the EPiImageResizer control using the e.Item.FindControl method and setting the PageLink using the value obtained from e.Item.DataItem.PageLink


As far I can see from the source code of EPiImage, it will not work/it's not supported. You could try setting the PageLink property for each item.


In EPiImage 2.5 the issue with databinding was fixed.

by specifying the both PropertyName and PageLink attribute it now works

<EPiImage:EPiImageResizer PropertyName="Image" PageLink="<%# Container.CurrentPage.PageLink %>" Width="150" Height="150" Transformation="ScaleToFill" runat="server" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜