Search code examples
asp.netkenticoascx

Inline Widgets in Kentico Repeater


I have a repeater that evaluates the content field from a page. This content may have inline widgets in it:

Now, normally I would wrap Eval("Content") in a placeholder with EnableViewState="false" and then resolve it dynamically in code behind but the problem is that the repeater repeats the ID for the placeholder rendering it invalid.

Is there anyway around this?

<cms:CMSUniView ID="MainNavMenu" runat="server" >
            <HeaderTemplate>
                <ul>
                <li>
            </HeaderTemplate>
            <ItemTemplate>
                <a href="<%# Eval("Link") %>"
                    title="<%# HTMLHelper.HTMLEncode( Convert.ToString(Eval("DocumentName"))) %>" >
                    <%# HTMLHelper.HTMLEncode( Convert.ToString(Eval("DocumentName"))) %>
                </a>
                <%# Eval("Content") %>
            </ItemTemplate>
            <SeparatorTemplate>
              </li>
              <li>
            </SeparatorTemplate>
            <FooterTemplate>
                </li>
                </ul>
            </FooterTemplate>
        </cms:CMSUniView>

Solution

  • You can try to resolve the content by using CMS.MacroEngine.MacroResolver.Resolve() method. So your code will look like:

    <%# MacroResolver.Resolve(Eval("Content").ToString()) %>
    

    And if you want to find any control inside a repeater template, I guess you should do it on ItemDataBound event. Example