Display default designer with embedded controls
I have created a wrapper around the NavigationControl so that we can have a title. Is there any way that we can use the default designer for the NavigationControl, or any default control, whenever they are embedded into a custom user control?
I currently do not have the NavControl exposed in the code behind in the attached code. I am just exposing the properties that we need to edit and assigning the values on the Page_Load event. If we cannot use the default designer is there a better way to do this?
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SiteMenuWithHeader.ascx.cs" Inherits="AkesocareWeb.UserControls.SiteMenuWithHeader" %><%@ Register TagPrefix="tk" Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.NavigationControls" %><div class="linkBox"> <h4><asp:Label runat="server" ID="txtNavHeading"></asp:Label></h4> <!-- Default control settings are in the code behind. --> <tk:NavigationControl ID="NavControl" runat="server" NavigationMode="VerticalSimple" SelectionMode="CurrentPageSiblings"></tk:NavigationControl></div>001.using System;002.using System.Collections.Generic;003.using System.Linq;004.using System.Web;005.using System.Web.UI.WebControls;006.using System.ComponentModel;007.using Telerik.Sitefinity;008.using Telerik.Sitefinity.Web;009.using Telerik.Sitefinity.Web.UI;010.using Telerik.Sitefinity.Web.UI.NavigationControls;011. 012.namespace AkesocareWeb.UserControls013.014. public partial class SiteMenuWithHeader : System.Web.UI.UserControl015. 016. 017. #region Fields018. 019. private PageSiteNode currentNode;020. private PageSiteNode parentNode;021. 022. private int? defaultMaxBindDepth = 1;023. private bool? defaultShowParentPage = false;024. private string defaultCssClass = "RadMenu_navigationsection";025. private string defaultSkin = "navigationsection";026. 027. #endregion028. 029. #region Properties030. 031. private PageSiteNode ParentNode032. 033. get034. 035. if (this.parentNode == null) GetParentNode();036. return this.parentNode;037. 038. 039. 040. private PageSiteNode CurrentNode041. 042. get043. 044. if (this.currentNode == null) GetCurrentNode();045. return this.currentNode;046. 047. 048. 049. public int? SiteMenu_MaxBindDepth050. 051. get return this.defaultMaxBindDepth; 052. set053. 054. if (value != null)055. this.defaultMaxBindDepth = value;056. 057. 058. 059. public bool? SiteMenu_ShowParentPage060. 061. get return this.defaultShowParentPage; 062. set063. 064. if (value != null)065. this.defaultShowParentPage = value;066. 067. 068. 069. public string SiteMenu_CssClass070. 071. get return this.defaultCssClass; 072. set073. 074. if (value != null)075. this.defaultCssClass = value;076. 077. 078. 079. public string SiteMenu_Skin080. 081. get return this.defaultSkin; 082. set083. 084. if (value != null)085. this.defaultSkin = value;086. 087. 088. 089. public string SiteMenu_Heading get; set; 090. 091. #endregion092. 093. #region Events094. 095. protected void Page_Load(object sender, EventArgs e)096. 097. SetMenuHeading();098. this.NavControl.CssClass = defaultCssClass;099. this.NavControl.Skin = defaultSkin;100. this.NavControl.ShowParentPage = (bool)defaultShowParentPage;101. this.NavControl.MaxDataBindDepth = (int)defaultMaxBindDepth;102. 103. 104. #endregion105. 106. #region Methods107. 108. 109. #region Private Methods110. 111. private void SetMenuHeading() 112. 113. if (!string.IsNullOrEmpty(this.SiteMenu_Heading))114. 115. this.txtNavHeading.Text = SiteMenu_Heading;116. 117. else118. 119. if (this.ParentNode != null)120. SetGroupTitle();121. else122. SetPageTitle();123. 124. 125. 126. private void GetCurrentNode()127. 128. this.currentNode = Telerik.Sitefinity.Web.SiteMapBase.GetActualCurrentNode();129. 130. 131. private void GetParentNode()132. 133. var currentNode = this.CurrentNode;134. PageSiteNode parentNode = null;135. if (currentNode != null)136. parentNode = currentNode.ParentNode as PageSiteNode;137. this.parentNode = (parentNode != null && parentNode.ParentKey != null) ?138. parentNode : null;139. 140. 141. private void SetPageTitle()142. 143. if (this.CurrentNode == null) return;144. this.txtNavHeading.Text = this.CurrentNode.Title;145. 146. 147. private void SetGroupTitle()148. 149. if (this.ParentNode == null) return;150. if (this.ParentNode.NodeType == Telerik.Sitefinity.Pages.Model.NodeType.Group)151. this.txtNavHeading.Text = this.ParentNode.Title;152. 153. 154. private bool IsCurrentNode(PageSiteNode node)155. 156. //Current node can be null when in design mode157. var currentNode = this.CurrentNode;158. bool result = false;159. if (currentNode != null)160. result = (node.PageId == this.CurrentNode.PageId);161. return result;162. 163. 164. 165. #endregion166. 167. 168. #region Public Methods169. 170. 171. #endregion172. 173. 174. #endregion175. 176.Hi,
You can use the navigation widget designer. To do this craete a class and inherit from Telerik.Sitefinity.Web.UI.NavigationControls.NavigationControl .
Register the class as a new user control. Go to Administration->Settings->Advanced->Toolboxes->Toolboxes->PageControls->Sections->NavigationSections->Tools and register the control as
ControlType: SitefinityWebApp.Class1 (namespace.classname of the newly created class)
Name: Class1
Title: CustomNavigation
To add the lable use a modified template for the navigation control where you can add the label.
The default template is:
<%@ Control Language="C#" %><%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sf" %><%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.NavigationControls.SiteMapNavigations" TagPrefix="navcontrols" %><%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %><sf:ConditionalTemplateContainer ID="conditionalTemplate" runat="server"> <Templates> <sf:ConditionalTemplate Left="NavigationMode" Operator="Equal" Right="HorizontalSimple" runat="server"> <navcontrols:SiteMapNavigationTabStrip ID="siteMapControl_horizontalsimple" runat="server" Skin="Sitefinity"> </navcontrols:SiteMapNavigationTabStrip> </sf:ConditionalTemplate> <sf:ConditionalTemplate Left="NavigationMode" Operator="Equal" Right="HorizontalDropDownMenu" runat="server"> <navcontrols:SiteMapNavigationMenu ID="siteMapControl_horizontaldropdownmenu" runat="server" Skin="Sitefinity" /> </sf:ConditionalTemplate> <sf:ConditionalTemplate Left="NavigationMode" Operator="Equal" Right="HorizontalTabs" runat="server"> <navcontrols:SiteMapNavigationTabStrip ID="siteMapControl_horizontaltabs" runat="server" Skin="Sitefinity"> </navcontrols:SiteMapNavigationTabStrip> </sf:ConditionalTemplate> <sf:ConditionalTemplate Left="NavigationMode" Operator="Equal" Right="VerticalSimple" runat="server"> <navcontrols:SiteMapNavigationTabStrip ID="siteMapControl_verticalsimple" runat="server" Orientation="VerticalLeft" MaxDataBindDepth="1" Skin="Sitefinity"> </navcontrols:SiteMapNavigationTabStrip> </sf:ConditionalTemplate> <sf:ConditionalTemplate Left="NavigationMode" Operator="Equal" Right="SiteMapInColumns" runat="server"> <navcontrols:SitemapNavigationSiteMapControl ID="siteMapControl_sitemapincolumns" runat="server" MaxDataBindDepth="2" Skin="Sitefinity"> <LevelSettings> <telerik:SiteMapLevelSetting Level="0"> <ListLayout RepeatDirection="Vertical" RepeatColumns="10" /> </telerik:SiteMapLevelSetting> </LevelSettings> </navcontrols:SitemapNavigationSiteMapControl> </sf:ConditionalTemplate> <sf:ConditionalTemplate Left="NavigationMode" Operator="Equal" Right="SiteMapInRows" runat="server"> <navcontrols:SitemapNavigationSiteMapControl ID="siteMapControl_sitemapinrows" runat="server" MaxDataBindDepth="2" Skin="Sitefinity"> <LevelSettings> <telerik:SiteMapLevelSetting> <ListLayout RepeatColumns="1" AlignRows="true" /> </telerik:SiteMapLevelSetting> <telerik:SiteMapLevelSetting Layout="Flow" SeparatorText="┊" /> </LevelSettings> </navcontrols:SitemapNavigationSiteMapControl> </sf:ConditionalTemplate> <sf:ConditionalTemplate Left="NavigationMode" Operator="Equal" Right="CustomNavigation" runat="server"> <telerik:RadSiteMap ID="siteMapControl_customnavigation" runat="server" Skin="Sitefinity" /> </sf:ConditionalTemplate> <sf:ConditionalTemplate Left="NavigationMode" Operator="Equal" Right="VerticalTree" runat="server"> <navcontrols:SiteMapNavigationTreeView runat="server" id="siteMapControl_verticaltree" Skin="Sitefinity"> </navcontrols:SiteMapNavigationTreeView> </sf:ConditionalTemplate> </Templates></sf:ConditionalTemplateContainer><script type="text/javascript"> function radMenuOnClick(sender, args) var state = args.get_item().get_attributes().getAttribute("ExpandOnClick"); args.get_item().get_attributes().setAttribute("ExpandOnClick", "true") args.get_item().open(); function radMenuOnOpening(sender, args) var state = args.get_item().get_attributes().getAttribute("ExpandOnClick"); if(state != "true") args.set_cancel(true); args.get_item().get_attributes().setAttribute("ExpandOnClick", "false") </script>public override string LayoutTemplatePath get string modeTemplate = null; if (string.IsNullOrWhiteSpace(modeTemplate) && string.IsNullOrWhiteSpace(this.LayoutTemplateName)) modeTemplate = NavigationControl.defaultEmbeddedLayoutTemplatePath; return modeTemplate; set return; public static readonly string defaultEmbeddedLayoutTemplatePath = ("SitefinityWebApp.CustomizedTemplate.ascx");