More in this section
Forums / General Discussions / Error with asp:Repeater in MasterPage template

Error with asp:Repeater in MasterPage template

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 0 answered
  1. Chris Bryant
    Chris Bryant avatar
    33 posts
    07 Jul 2009
    31 Mar 2011
    Link to this post
    I have a MasterPage template that uses an aspnet Repeater control.  This works fine when viewing the page directly; however, when editting the page in Sitefinity, I get the following error:

    Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.

    Here is the markup:

        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
            <asp:Repeater ID="ItemRepeater" runat="server">
                    <li class="Item"><a href="<%# Eval("Url") %>"><%# Eval("Title") %></a></li>
        <div id="contentwindow">
            <div id="Content">
                <div id="ContentBlockMain">
                    <asp:ContentPlaceHolder ID="ContentBlock" runat="server" />

    The ItemRepeater.DataBind() is being invoked in Page_Load() of the MasterPage.

    Any idea what could be causing this?  Is there a workaround, or from the MasterPage codebehind, can I detect if the page is being displayed through Sitefinity and act accordingly?

    -Chris B.

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    05 Apr 2011
    Link to this post
    Hello Chris Bryant,

    There are control extensions - ControlExtensions

    IsDesignMode - static method which determines whether the control is in Sitefinity design mode - you  are editing a page. There are also

    IsPreviewMode- determines whether the control is in Sitefinity preview mode.

    IsBackend -determines whether a control instance is in backend.



    protected override void OnPreRender(EventArgs e)
            if (this.IsDesignMode() && !this.IsPreviewMode())

    You can use one of the methods below to disable the control binding/rendering and suppress the error you are getting.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

2 posts, 0 answered