我正在使用 Sitecore 并使用 VS2010(版本 4)。我根据标签索引用户从后面的代码中添加属性:
Link hlTabLink;
i = e.Item.DataItem as Item;
hlTabLink = e.Item.FindControl("hlTabLink") as Link;
hlTabLink.Target = Sitecore.Links.LinkManager.GetItemUrl(i);
hlTabLink.DataSource = i.Paths.FullPath;
hlTabLink.Field = "Title";
String liContainerId;
switch (hlTabLink.TabIndex) //Switch case statements for the tab navigation.
{
case 0:
liContainerId = "tab-label TabbedPanelsTabSelected";
hlTabLink.Attributes.Add("class", liContainerId);
break;
case 1:
liContainerId = "tab-label TabbedPanelsTabSelected";
hlTabLink.Attributes.Add("class", liContainerId);
break;
case 2:
liContainerId = "tab-label last";
hlTabLink.Attributes.Add("class", liContainerId);
break;
}
这是 .ascx 控件的标记:
<div class="tab-panels" id="TabbedPanels1">
<ul id="Tab-labels">
<asp:Repeater ID="rptTab" runat="server" OnItemDataBound="rptTab_ItemBound">
<ItemTemplate>
<li>
<sc:Link ID = "hlTabLink" Field = "scTabLink" runat ="server"></sc:Link>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
渲染后我的标记看起来像这样:
<div class="tab-panels" id="TabbedPanels1">
<ul id="Tab-labels">
<li>
Overview
</li>
<li>
Why Me
</li>
</ul>
我在这里做错了什么?