This is a migrated thread and some comments may be shown as answers.

The Controls collection cannot be modified because the control contains code blocks Error please help!

2 Answers 132 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
maurice
Top achievements
Rank 1
maurice asked on 07 Oct 2011, 11:19 AM
I tried searching to see what was going on here. I have a user control that is not working right please help me.

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

<%@ Import Namespace="Telerik.Web.UI" %>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script runat="server">
        void AlbumSetup(object sender, RadListViewItemEventArgs e)
        {
            RadListViewDataItem item = (RadListViewDataItem)e.Item;
            ImageButton Imagebutton = (ImageButton)e.Item.FindControl("AlbumImage");
            HyperLink EditAlbum = (HyperLink)e.Item.FindControl("EditAlbum");
            HyperLink sHyperLink = (HyperLink)e.Item.FindControl("hypShareAlbum");
            HyperLink DeleteAlbums = (HyperLink)e.Item.FindControl("hypeDeleteAlbum");
            HyperLink DeleteAccess = (HyperLink)e.Item.FindControl("hypeDeleteMyAccess");
            HiddenField sharecounter = (HiddenField) e.Item.FindControl("ShareCounter");
            mygreatappz.control.Objects.Album album = item.DataItem as mygreatappz.control.Objects.Album;

            if (album != null)
            {
                if (album.AlbumDefaultImageUrl ==
                    "https://lh5.googleusercontent.com/-d8vnGzfqf_M/TnNs5XN0vfI/AAAAAAAAAEs/sIWhb9-7BE4/s128/no_pic302765EC-7C31-424E-AA45-FC279C6E4A66.png")
                {
                    album.AlbumDefaultImageUrl = "~/SiteImages/no_pic302765EC-7C31-424E-AA45-FC279C6E4A66 (1).png";
                }
                if (DeleteAlbums != null && album.CreatorID == PictureCrave.GlobalClass.GlobalVariables.User.ID)
                {
                    DeleteAlbums.Visible = true;
                }
                else
                {
                    if (DeleteAccess != null)
                    {
                        DeleteAccess.Visible = true;
                    }
                }
                Imagebutton.PostBackUrl = "../SitePages/AlbumView.aspx?aid=" + album.ID;
                EditAlbum.NavigateUrl = "../SitePages/AlbumView.aspx?aid=" + album.ID;
                sHyperLink.Text = string.Format("Share Album ({0})", album.AccessCount);
                sharecounter.Value = album.AccessCount.ToString();
            }
        }
        
        </script>
</telerik:RadCodeBlock>

<div id="divFullControlAlbums">
        <asp:HiddenField runat="server" ID="FullAlbumCounter"/>
            <h2>
                Full control albums:</h2>
                 <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="ListViewPanel1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="ListViewPanel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="CheckBoxList1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="ListViewPanel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" MinDisplayTime="0" />
        <asp:Panel ID="ListViewPanel1" runat="server">
                  <telerik:RadListView ID="lvFullControlAlbums" AllowPaging="true" runat="server" GroupItemCount="5" OnItemDataBound="AlbumSetup"
                   >
                  <LayoutTemplate>
                    <table id="Table2" runat="server">
                        <tr id="Tr1" runat="server">
                            <td id="Td3" runat="server">
                                <table id="groupPlaceholderContainer" runat="server" border="0" style="">
                                    <tr id="groupPlaceholder" runat="server">
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr id="Tr2" runat="server">
                            <td id="Td4" runat="server" style="">
                            <telerik:RadDataPager ID="RadDataPager1" runat="server" PagedControlID="lvFullControlAlbums"
                                        PageSize="10">
                                        <Fields>
                                           
                                            <telerik:RadDataPagerButtonField FieldType="Numeric" />
                                           
                                            <telerik:RadDataPagerTemplatePageField>
                                                <PagerTemplate>
                                                    <div style="float: right">
                                                        <b>Items
                                                            <asp:Label runat="server" ID="CurrentPageLabel" Text="<%# Container.Owner.StartRowIndex+1%>" />
                                                            to
                                                            <asp:Label runat="server" ID="TotalPagesLabel" Text="<%# Container.Owner.TotalRowCount > (Container.Owner.StartRowIndex+Container.Owner.PageSize) ? Container.Owner.StartRowIndex+Container.Owner.PageSize : Container.Owner.TotalRowCount %>" />
                                                            of
                                                            <asp:Label runat="server" ID="TotalItemsLabel" Text="<%# Container.Owner.TotalRowCount%>" />
                                                            <br />
                                                        </b>
                                                    </div>
                                                </PagerTemplate>
                                            </telerik:RadDataPagerTemplatePageField>
                                        </Fields>
                                    </telerik:RadDataPager>
                            </td>
                        </tr>
                    </table>
                </LayoutTemplate>
                    <EmptyDataTemplate>
                    <table id="Table1" runat="server" style="">
                        <tr>
                            <td>
                                No data was returned.
                            </td>
                        </tr>
                    </table>
                </EmptyDataTemplate>
                <EmptyItemTemplate>
                    <td id="Td1" runat="server" />
                </EmptyItemTemplate>
                
                <ItemTemplate>
                    <td id="Td2" runat="server" style="display: inline-block; position: relative; margin: 0.7em;
                        text-align: left; vertical-align: top;">
                        <asp:HiddenField runat="server" ID="ShareCounter"/>
                        <div id="HypeShareAlbum" style="padding: 0; margin: 0">
                            <input type="hidden" value="<%#Eval("ID") %>" />
                            <asp:HyperLink runat="server" ID="hypShareAlbum"></asp:HyperLink>
                             <input type="hidden" value="<%#Eval("CreatorID") %>"/>
                             </div>
                        <div class="EditAlbumClass">
                            <asp:ImageButton ToolTip='<%#Eval("AlbumDescription") %>' runat="server" ID="AlbumImage" Width="110"
                                Height="110" ImageUrl='<%#Eval("AlbumDefaultImageUrl") %>' /></div>
                        <img src="../SiteImages/private.png" style="margin: 0" />
                        <span style="margin: 0">photos:
                            <%#Eval("PhotoCount")%></span><br />
                        <div id="hypDeleteAccess" style="padding: 0; margin: 0">
                            <input type="hidden" value="<%#Eval("ID") %>" />
                            <asp:HyperLink runat="server" ID="hypeDeleteAlbum" Visible="false" Text="Delete Album"></asp:HyperLink>
                            <asp:HyperLink ID="hypeDeleteMyAccess" runat="server" Visible="false" Text="Remove my Access"></asp:HyperLink>
                            
                        </div>
                        <div  class="EditAlbumClass">
                            <asp:HyperLink runat="server" ID="EditAlbum" ToolTip='<%#Eval("AlbumDescription") %>' Font-Underline="false">
                            <p class="titleAlbums" runat="server" id="pTitle">
                                <%#Eval("AlbumName") %></p>
                        </asp:HyperLink></div>
                    </td>
                </ItemTemplate>
                <GroupTemplate>
                    <tr id="itemPlaceholderContainer" runat="server">
                        <td id="itemPlaceholder" runat="server">
                        </td>
                    </tr>
                </GroupTemplate>
                  </telerik:RadListView>
            </asp:Panel>
            </
            
        </div>

2 Answers, 1 is accepted

Sort by
0
maurice
Top achievements
Rank 1
answered on 07 Oct 2011, 03:23 PM
Anyone?
0
Shinu
Top achievements
Rank 2
answered on 10 Oct 2011, 10:27 AM
Hello Maurice,

If you have any code blocks you can enclose them using telerik:RadCodeBlock tag.

Also take a look into the following help article which explains more on the same scenario.
General Troubleshooting.

Thanks,
Shinu.
Tags
General Discussions
Asked by
maurice
Top achievements
Rank 1
Answers by
maurice
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or