简体   繁体   English

无法修改控件集合,因为控件包含代码块错误

[英]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>

在有问题的代码周围使用RadCodeBlockRadScriptBlock

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 “控件集合无法修改,因为控件包含代码块” - "The Controls collection cannot be modified because the control contains code blocks" 无法修改控件集合,因为控件包含代码块 - The Controls collection cannot be modified because the control contains code blocks 无法修改控件集合,因为控件包含代码块(即&lt;%…%&gt;)错误,无法正常工作 - The Controls collection cannot be modified because the control contains code blocks (i.e. <% … %>) error not working 无法修改控件集合,因为控件包含代码块(即&lt;%…%&gt;)错误 - The Controls collection cannot be modified because the control contains code blocks (i.e. <% … %>) error “由于控件包含代码块(即&lt;%…%&gt;)而无法修改Controls集合”的修补程序后的代码 - Code behind fix for “ The Controls collection cannot be modified because the control contains code blocks (i.e. <% … %>)” 无法修改控件集合,因为控件包含代码块(即&lt;%…%&gt;)javascript - The Controls collection cannot be modified because the control contains code blocks (i.e. <% … %>) javascript 无法修改Controls集合,因为控件包含代码块(即<%...%>) - The Controls collection cannot be modified because the control contains code blocks (i.e. <% … %>) 是什么原因导致“由于控件包含代码块而无法修改控件集合”? - What causes “ Controls collection cannot be modified because the control contains code blocks”? 无法修改Controls集合,因为控件包含代码块(即&lt;%...%&gt;) - The Controls collection cannot be modified because the control contains code blocks (i.e. <% … %>) 无法修改Controls集合,因为控件包含代码块(即<%...%>) - The Controls collection cannot be modified because the control contains code blocks (i.e. <% … %>)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM