protected override void OnInit(EventArgs e) { this.Controls.Clear(); base.OnInit(e); LoadData(); if (TopNavHeaderTemplate == null || TopNavFooterTemplate == null) { TopNavHeaderTemplate = new DefaultListOpenNavTemplate(); TopNavFooterTemplate = new DefaultListCloseNavTemplate(); } if (SubNavHeaderTemplate == null || SubNavFooterTemplate == null) { SubNavHeaderTemplate = new DefaultListOpenNavTemplate(); SubNavFooterTemplate = new DefaultListCloseNavTemplate(); } if (TopNavTemplate == null) { TopNavTemplate = new DefaultLinkNavTemplate(); } if (SubNavTemplate == null) { SubNavTemplate = new DefaultLinkNavTemplate(); } List <SiteNav> lstTop = GetTopNav(); rTopNav.ID = this.ClientID + "_rTopNav"; rTopNav.HeaderTemplate = TopNavHeaderTemplate; rTopNav.ItemTemplate = TopNavTemplate; rTopNav.FooterTemplate = TopNavFooterTemplate; this.Controls.Add(rTopNav); rTopNav.DataSource = lstTop; rTopNav.DataBind(); if (ShowSecondLevel) { int iMax = lstTop.Count; for (int iIdx = 0; iIdx < iMax; iIdx++) { SetSubNav(rTopNav.Items[iIdx], lstTop[iIdx].Root_ContentID); } } }
protected void SetSubNav(RepeaterItem container, Guid rootContentID) { Control ctrl = FindSubControl(container); if (ctrl == null) { ctrl = new ListItemPlaceHolder(); container.Controls.Add(ctrl); } else { Control ctrl2 = FindSubControl(ctrl); if (ctrl2 != null) { ctrl = ctrl2; } } List <SiteNav> lstNav = GetChildren(rootContentID); if (lstNav != null && lstNav.Any()) { ListItemRepeater rSubNav = new ListItemRepeater(); rSubNav.ID = "rSubNav"; rSubNav.HeaderTemplate = SubNavHeaderTemplate; rSubNav.ItemTemplate = SubNavTemplate; rSubNav.FooterTemplate = SubNavFooterTemplate; ctrl.Controls.Add(rSubNav); rSubNav.DataSource = lstNav; rSubNav.DataBind(); rSubNav.EnableViewState = this.EnableViewState; UpdateHyperLink(rSubNav); } }
protected void SetSubNav(RepeaterItem container, Guid rootContentID) { Control ctrl = FindSubControl(container); if (ctrl == null) { ctrl = new ListItemPlaceHolder(); container.Controls.Add(ctrl); } else { Control ctrl2 = FindSubControl(ctrl); if (ctrl2 != null) { ctrl = ctrl2; } } List<SiteNav> lstNav = GetChildren(rootContentID); if (lstNav != null && lstNav.Any()) { ListItemRepeater rSubNav = new ListItemRepeater(); rSubNav.ID = "rSubNav"; rSubNav.HeaderTemplate = SubNavHeaderTemplate; rSubNav.ItemTemplate = SubNavTemplate; rSubNav.FooterTemplate = SubNavFooterTemplate; ctrl.Controls.Add(rSubNav); rSubNav.DataSource = lstNav; rSubNav.DataBind(); rSubNav.EnableViewState = this.EnableViewState; UpdateHyperLink(rSubNav); } }