Sitecore ChromesTypes(动态占位符)在WebForm中

时间:2014-12-16 09:05:35

标签: asp.net dynamic sitecore placeholder sitecore7

我有一个转发器来生成动态占位符。在编辑模式下,当我为它选择一个usercontrol时,它向我发送一个错误:“尝试从服务器渲染html时未捕获的意外元素。期望最后一个标记关闭脚本标记16860737917440451880.js:5353 Sitecore.PageModes.ChromeTypes.Placeholder .Sitecore.PageModes.ChromeTypes.ChromeType.extend._frameLoaded“

请帮助我,tks和最好的考虑

喜欢这个问题:http://developmentsitecore.blogspot.com/search?q=Expecting+last+tag+to+be+closing+script+marker 但我在网络应用程序中编码

这是ascx文件

<asp:Repeater ID="rpAccordion" runat="server" OnItemDataBound="rpAccordion_OnItemDataBound">
    <ItemTemplate>
         <asp:Label runat="server" ID="lblPageHeading" Text='<%#DataBinder.Eval(Container.DataItem,"Name") %>'></asp:Label>
        <div>
        <p>
             <sc:Placeholder ClientIDMode="Static" ID="Accordion_dynamic_1" runat="server" Key="phMenuAccordion_dynamic_1" />
        </p>
           </div>
    </ItemTemplate>
</asp:Repeater>

这是ascx.cs文件

protected void Page_Load(object sender, EventArgs e)
    {
        Item source = GetItem();
        if (source != null && source.GetChildren().Count > 0)
        {
            var filterSource = source.GetChildren().Where(s => s.Version != null && s.Versions.Count > 0).ToList();
            if (filterSource.Count > 0)
            {
                rpAccordion.DataSource = filterSource;
                rpAccordion.DataBind();
            }
        }
    }

    protected void rpAccordion_OnItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        try
        {
            var currentItem = (Item)e.Item.DataItem;
            if (currentItem != null && e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var placeHolderAccordion = e.Item.FindControl("Accordion_dynamic_1") as Placeholder;
                if (placeHolderAccordion != null)
                {
                    placeHolderAccordion.ID = "Accordion_dynamic_" + Convert.ToInt32(e.Item.ItemIndex + 1);
                    placeHolderAccordion.Key = "Accordion_dynamic_" + Convert.ToInt32(e.Item.ItemIndex + 1);
                }
            }
        }
        catch (Exception ex)
        {
            Log.Error(ex.Message, ex, this);
        }
    }

我制作这些动态占位符可编辑到位置设置

0 个答案:

没有答案