开发者

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

Seems like everyone has there own story when it comes to this so here is mine.

<%

@ Import Namespace="Telerik.Web.UI" %>
<telerik:RadCodeBlock ID="RadCodeBlock2" 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>

        </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>


Use a RadCodeBlock or a RadScriptBlock around the offending code.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜