0
我有2個標籤作爲一個Sitecore.Web.UI.WebControls.Link鏈接。現在,當頁面開放時,我想專注於第一個。我寫了這段代碼,但似乎只有它的第二個索引2次。所以我得到了兩個選項卡作爲選定的項目。這裏是代碼:如何關注sitecore中的選項卡?
protected void rptTab_ItemBound(Object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Item i = e.Item.DataItem as Item;
Link hlTabLink;
HtmlControl liHTML;
liHTML = e.Item.FindControl("liTabTest") as HtmlControl;
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";
liHTML.Attributes.Add("class", liContainerId);
break;
case 1:
liContainerId = "tab-label TabbedPanelsTabSelected";
hlTabLink.CssClass = "tab-label TabbedPanelsTabSelected";
break;
case 2:
liContainerId = "tab-label last";
hlTabLink.Attributes.Add("class", liContainerId);
break;
}
}
案例0擊中2次。正如你所看到的標籤在中繼器中。以下是一個標記:由於數據綁定的DOM更新之前完成
<asp:Repeater ID="rptTab" runat="server" OnItemDataBound="rptTab_ItemBound">
<ItemTemplate>
<li id= "liTabTest" runat = "server">
<a>
<sc:Link ID = "hlTabLink" Field = "scTabLink" runat ="server"></sc:Link>
</a>
</li>
</ItemTemplate>
</asp:Repeater>