Literal CreateLiteral(SiteMapNodeItem item)
        {
            Literal h = new Literal();

            h.Text = item.SiteMapNode.Title;
            return(h);
        }
Exemple #2
0
        private SiteMapNodeItem CreateItem(int itemIndex, SiteMapNodeItemType itemType, SiteMapNode node)
        {
            SiteMapNodeItem item = new SiteMapNodeItem(itemIndex, itemType);

            int index = (PathDirection == PathDirection.CurrentToRoot ? 0 : -1);

            SiteMapNodeItemEventArgs e = new SiteMapNodeItemEventArgs(item);

            //Add sitemap nodes so that they are accessible during events.
            item.SiteMapNode = node;
            InitializeItem(item);

            // Notify items
            OnItemCreated(e);

            // Add items based on PathDirection.
            Controls.AddAt(index, item);

            // Databind.
            item.DataBind();

            // Notify items.
            OnItemDataBound(e);

            item.SiteMapNode = null;

            // SiteMapNodeItem is dynamically created each time, don't track viewstate.
            item.EnableViewState = false;

            return(item);
        }
        HyperLink CreateHyperLink(SiteMapNodeItem item)
        {
            HyperLink h = new HyperLink();

            h.Text        = item.SiteMapNode.Title;
            h.NavigateUrl = item.SiteMapNode.Url;
            if (ShowToolTips)
            {
                h.ToolTip = item.SiteMapNode.Description;
            }
            return(h);
        }
        public override void DataBind()
        {
            base.DataBind();

            /* the child controls get bound in
             * base.DataBind */
            foreach (Control c in Controls)
            {
                if (c is SiteMapNodeItem)
                {
                    SiteMapNodeItem it = (SiteMapNodeItem)c;
                    OnItemDataBound(new SiteMapNodeItemEventArgs(it));
                }
            }
        }
Exemple #5
0
        private SiteMapNodeItem CreateItem(int itemIndex, SiteMapNodeItemType itemType, SiteMapNode node)
        {
            SiteMapNodeItem          item  = new SiteMapNodeItem(itemIndex, itemType);
            int                      index = (this.PathDirection == System.Web.UI.WebControls.PathDirection.CurrentToRoot) ? 0 : -1;
            SiteMapNodeItemEventArgs e     = new SiteMapNodeItemEventArgs(item);

            item.SiteMapNode = node;
            this.InitializeItem(item);
            this.OnItemCreated(e);
            this.Controls.AddAt(index, item);
            item.DataBind();
            this.OnItemDataBound(e);
            item.SiteMapNode     = null;
            item.EnableViewState = false;
            return(item);
        }
        protected override void InitializeItem(SiteMapNodeItem item)
        {
            if (item.SiteMapNode == null)
            {
                base.InitializeItem(item);
                return;
            }

            HyperLink hLink = new HyperLink();

            hLink.EnableTheming = false;
            hLink.Enabled = this.Enabled;

            if (UrlTransform != null)
                hLink.NavigateUrl = UrlTransform(item.SiteMapNode.Url);
            else
                hLink.NavigateUrl = item.SiteMapNode.Url;
            hLink.Text = item.SiteMapNode.Title;
            if (ShowToolTips)
                hLink.ToolTip = item.SiteMapNode.Description;

            item.Controls.Add(hLink);
        }
		public static void InitializeItemPathSeparator (Page p)
		{
			PokerSiteMapPath smp = new PokerSiteMapPath ();
			SiteMapNodeItem I = new SiteMapNodeItem (0, SiteMapNodeItemType.PathSeparator);
			smp.PathSeparatorStyle.BorderColor = Color.Red;
			smp.InitilizeItems (I);
			Assert.AreEqual (1, I.Controls.Count, "InitializeItem#1");
			Assert.AreEqual (typeof (Literal), I.Controls[0].GetType (), "InitializeItem#2");
			Assert.AreEqual (Color.Red, I.BorderColor, "InitializeItem#3");
		}
		public static void InitializeItemTemplates (Page p)
		{
			PokerSiteMapPath smp = new PokerSiteMapPath ();
			SiteMapNodeItem I = new SiteMapNodeItem (1, SiteMapNodeItemType.Current);
			smp.CurrentNodeTemplate = new CompiledTemplateBuilder (templatebuilder);
			smp.CurrentNodeStyle.BackColor = Color.Red;
			smp.DoCreateControlHierarchy ();
			I.SiteMapNode = smp.Provider.CurrentNode;
			smp.InitilizeItems (I);

			Assert.AreEqual (1, I.Controls.Count, "InitializeItem#1");
			Assert.AreEqual (typeof (TextBox), I.Controls[0].GetType (), "InitializeItem#2");
			Assert.AreEqual (Color.Red, I.BackColor, "InitializeItem#3");
		}
		public static void InitializeItemCurrent (Page p)
		{
			PokerSiteMapPath smp = new PokerSiteMapPath ();
			SiteMapNodeItem I = new SiteMapNodeItem (1, SiteMapNodeItemType.Current);
			smp.CurrentNodeStyle.BackColor = Color.Red;
			smp.NodeStyle.BorderColor = Color.Red;
			smp.DoCreateControlHierarchy ();
			I.SiteMapNode = smp.Provider.CurrentNode;
			smp.InitilizeItems (I);
			
			Assert.AreEqual (1, I.Controls.Count, "InitializeItem#1");
			Assert.AreEqual (typeof (Literal), I.Controls[0].GetType (), "InitializeItem#2");
		        Assert.AreEqual (Color.Red, I.BackColor , "InitializeItem#3");
			Assert.AreEqual (Color.Red, I.BorderColor, "InitializeItem#4");

			I.Controls.Clear ();
			smp.RenderCurrentNodeAsLink = true;
			smp.InitilizeItems (I);
			
			Assert.AreEqual (1, I.Controls.Count, "InitializeItem#5");
			Assert.AreEqual (typeof (HyperLink), I.Controls[0].GetType (), "InitializeItem#6");
			Assert.AreEqual (Color.Red, I.BackColor, "InitializeItem#7");
			Assert.AreEqual (Color.Red, I.BorderColor, "InitializeItem#8");
		}
		public static void InitializeItemParent (Page p)
		{
			PokerSiteMapPath smp = new PokerSiteMapPath ();
			SiteMapNodeItem I = new SiteMapNodeItem (0, SiteMapNodeItemType.Parent);
			smp.NodeStyle.BorderColor = Color.Red;
			smp.DoCreateControlHierarchy ();
			I.SiteMapNode = smp.Provider.RootNode;
			smp.InitilizeItems (I);

			Assert.AreEqual (1, I.Controls.Count, "InitializeItem#1");
			Assert.AreEqual (typeof (HyperLink), I.Controls[0].GetType (), "InitializeItem#2");
			Assert.AreEqual (Color.Red, ((HyperLink) I.Controls[0]).ControlStyle.BorderColor, "InitializeItem#4");
		}
        protected virtual void InitializeItem(SiteMapNodeItem item)
        {
            ITemplate nodeTemplate = null;
            Style s = null;
            SiteMapNodeItemType itemType = item.ItemType;
            SiteMapNode siteMapNode = item.SiteMapNode;
            switch (itemType)
            {
                case SiteMapNodeItemType.Root:
                    nodeTemplate = (this.RootNodeTemplate != null) ? this.RootNodeTemplate : this.NodeTemplate;
                    s = this._mergedRootNodeStyle;
                    break;

                case SiteMapNodeItemType.Parent:
                    nodeTemplate = this.NodeTemplate;
                    s = this._nodeStyle;
                    break;

                case SiteMapNodeItemType.Current:
                    nodeTemplate = (this.CurrentNodeTemplate != null) ? this.CurrentNodeTemplate : this.NodeTemplate;
                    s = this._mergedCurrentNodeStyle;
                    break;

                case SiteMapNodeItemType.PathSeparator:
                    nodeTemplate = this.PathSeparatorTemplate;
                    s = this._pathSeparatorStyle;
                    break;
            }
            if (nodeTemplate == null)
            {
                if (itemType == SiteMapNodeItemType.PathSeparator)
                {
                    Literal child = new Literal {
                        Mode = LiteralMode.Encode,
                        Text = this.PathSeparator
                    };
                    item.Controls.Add(child);
                    item.ApplyStyle(s);
                }
                else if ((itemType == SiteMapNodeItemType.Current) && !this.RenderCurrentNodeAsLink)
                {
                    Literal literal2 = new Literal {
                        Mode = LiteralMode.Encode,
                        Text = siteMapNode.Title
                    };
                    item.Controls.Add(literal2);
                    item.ApplyStyle(s);
                }
                else
                {
                    HyperLink link = new HyperLink();
                    if ((s != null) && s.IsSet(0x2000))
                    {
                        link.Font.Underline = s.Font.Underline;
                    }
                    link.EnableTheming = false;
                    link.Enabled = this.Enabled;
                    if (siteMapNode.Url.StartsWith(@"\\", StringComparison.Ordinal))
                    {
                        link.NavigateUrl = base.ResolveClientUrl(HttpUtility.UrlPathEncode(siteMapNode.Url));
                    }
                    else
                    {
                        link.NavigateUrl = (this.Context != null) ? this.Context.Response.ApplyAppPathModifier(base.ResolveClientUrl(HttpUtility.UrlPathEncode(siteMapNode.Url))) : siteMapNode.Url;
                    }
                    link.Text = HttpUtility.HtmlEncode(siteMapNode.Title);
                    if (this.ShowToolTips)
                    {
                        link.ToolTip = siteMapNode.Description;
                    }
                    item.Controls.Add(link);
                    link.ApplyStyle(s);
                }
            }
            else
            {
                nodeTemplate.InstantiateIn(item);
                item.ApplyStyle(s);
            }
        }
 protected virtual new void InitializeItem(SiteMapNodeItem item)
 {
 }
Exemple #13
0
        /// <devdoc>
        /// <para>A protected method. Populates iteratively the specified <see cref='System.Web.UI.WebControls.SiteMapNodeItem'/> with a
        ///    sub-hierarchy of child controls.</para>
        /// </devdoc>
        protected virtual void InitializeItem(SiteMapNodeItem item)
        {
            Debug.Assert(_mergedCurrentNodeStyle != null && _mergedRootNodeStyle != null);

            ITemplate           template = null;
            Style               style    = null;
            SiteMapNodeItemType itemType = item.ItemType;
            SiteMapNode         node     = item.SiteMapNode;

            switch (itemType)
            {
            case SiteMapNodeItemType.Root:
                template = RootNodeTemplate != null ? RootNodeTemplate : NodeTemplate;
                style    = _mergedRootNodeStyle;
                break;

            case SiteMapNodeItemType.Parent:
                template = NodeTemplate;
                style    = _nodeStyle;
                break;

            case SiteMapNodeItemType.Current:
                template = CurrentNodeTemplate != null ? CurrentNodeTemplate : NodeTemplate;
                style    = _mergedCurrentNodeStyle;
                break;

            case SiteMapNodeItemType.PathSeparator:
                template = PathSeparatorTemplate;
                style    = _pathSeparatorStyle;
                break;
            }

            if (template == null)
            {
                if (itemType == SiteMapNodeItemType.PathSeparator)
                {
                    Literal separatorLiteral = new Literal();
                    separatorLiteral.Mode = LiteralMode.Encode;
                    separatorLiteral.Text = PathSeparator;
                    item.Controls.Add(separatorLiteral);
                    item.ApplyStyle(style);
                }
                else if (itemType == SiteMapNodeItemType.Current && !RenderCurrentNodeAsLink)
                {
                    Literal currentNodeLiteral = new Literal();
                    currentNodeLiteral.Mode = LiteralMode.Encode;
                    currentNodeLiteral.Text = node.Title;
                    item.Controls.Add(currentNodeLiteral);
                    item.ApplyStyle(style);
                }
                else
                {
                    HyperLink link = new HyperLink();

                    if (style != null && style.IsSet(System.Web.UI.WebControls.Style.PROP_FONT_UNDERLINE))
                    {
                        link.Font.Underline = style.Font.Underline;
                    }

                    link.EnableTheming = false;
                    link.Enabled       = this.Enabled;
                    // VSWhidbey 281869 Don't modify input when url pointing to unc share
                    if (node.Url.StartsWith("\\\\", StringComparison.Ordinal))
                    {
                        link.NavigateUrl = ResolveClientUrl(HttpUtility.UrlPathEncode(node.Url));
                    }
                    else
                    {
                        link.NavigateUrl = Context != null?
                                           Context.Response.ApplyAppPathModifier(ResolveClientUrl(HttpUtility.UrlPathEncode(node.Url))) : node.Url;
                    }
                    link.Text = HttpUtility.HtmlEncode(node.Title);
                    if (ShowToolTips)
                    {
                        link.ToolTip = node.Description;
                    }
                    item.Controls.Add(link);
                    link.ApplyStyle(style);
                }
            }
            else
            {
                template.InstantiateIn(item);
                item.ApplyStyle(style);
            }
        }
        private SiteMapNodeItem CreateItem(int itemIndex, SiteMapNodeItemType itemType, SiteMapNode node) {
            SiteMapNodeItem item = new SiteMapNodeItem(itemIndex, itemType);

            int index = (PathDirection == PathDirection.CurrentToRoot ? 0 : -1);

            SiteMapNodeItemEventArgs e = new SiteMapNodeItemEventArgs(item);

            //Add sitemap nodes so that they are accessible during events.
            item.SiteMapNode = node;
            InitializeItem(item);

            // Notify items
            OnItemCreated(e);

            // Add items based on PathDirection.
            Controls.AddAt(index, item);

            // Databind.
            item.DataBind();

            // Notify items.
            OnItemDataBound(e);

            item.SiteMapNode = null;

            // SiteMapNodeItem is dynamically created each time, don't track viewstate.
            item.EnableViewState = false;

            return item;
        }
 public SiteMapNodeItemEventArgs(SiteMapNodeItem item)
 {
     this._item = item;
 }
        protected virtual void InitializeItem(SiteMapNodeItem item)
        {
            switch (item.ItemType)
            {
            case SiteMapNodeItemType.Root:
                if (RootNodeTemplate != null)
                {
                    item.ApplyStyle(NodeStyle);
                    item.ApplyStyle(RootNodeStyle);
                    RootNodeTemplate.InstantiateIn(item);
                }
                else if (NodeTemplate != null)
                {
                    item.ApplyStyle(NodeStyle);
                    item.ApplyStyle(RootNodeStyle);
                    NodeTemplate.InstantiateIn(item);
                }
                else
                {
                    WebControl c = CreateHyperLink(item);
                    c.ApplyStyle(NodeStyle);
                    c.ApplyStyle(RootNodeStyle);
                    item.Controls.Add(c);
                }
                break;

            case SiteMapNodeItemType.Current:
                if (CurrentNodeTemplate != null)
                {
                    item.ApplyStyle(NodeStyle);
                    item.ApplyStyle(CurrentNodeStyle);
                    CurrentNodeTemplate.InstantiateIn(item);
                }
                else if (NodeTemplate != null)
                {
                    item.ApplyStyle(NodeStyle);
                    item.ApplyStyle(CurrentNodeStyle);
                    NodeTemplate.InstantiateIn(item);
                }
                else if (RenderCurrentNodeAsLink)
                {
                    HyperLink c = CreateHyperLink(item);
                    c.ApplyStyle(NodeStyle);
                    c.ApplyStyle(CurrentNodeStyle);
                    item.Controls.Add(c);
                }
                else
                {
                    Literal c = CreateLiteral(item);
                    item.ApplyStyle(NodeStyle);
                    item.ApplyStyle(CurrentNodeStyle);
                    item.Controls.Add(c);
                }
                break;

            case SiteMapNodeItemType.Parent:
                if (NodeTemplate != null)
                {
                    item.ApplyStyle(NodeStyle);
                    NodeTemplate.InstantiateIn(item);
                }
                else
                {
                    WebControl c = CreateHyperLink(item);
                    c.ApplyStyle(NodeStyle);
                    item.Controls.Add(c);
                }
                break;

            case SiteMapNodeItemType.PathSeparator:
                if (PathSeparatorTemplate != null)
                {
                    item.ApplyStyle(PathSeparatorStyle);
                    PathSeparatorTemplate.InstantiateIn(item);
                }
                else
                {
                    Literal h = new Literal();
                    h.Text = HttpUtility.HtmlEncode(PathSeparator);
                    item.ApplyStyle(PathSeparatorStyle);
                    item.Controls.Add(h);
                }
                break;
            }
        }
		public void Events (Page p)
		{
			PokerSiteMapPath smp = new PokerSiteMapPath ();
			ResetEvents ();
			smp.DataBinding += new EventHandler (DataBindingHandler);
			smp.ItemDataBound += new SiteMapNodeItemEventHandler (ItemDataBoundHandler);
			smp.ItemCreated += new SiteMapNodeItemEventHandler (ItemCreatedHandler);

			Assert.AreEqual (false, DataBinding, "BeforeDataBinding");
			smp.DoOnDataBinding (new EventArgs ());
			Assert.AreEqual (true, DataBinding, "AfterDataBinding");

			ResetEvents ();
			Assert.AreEqual (false, ItemDataBounding, "BeforeItemDataBound");
			SiteMapNodeItem i = new SiteMapNodeItem (0, SiteMapNodeItemType.Root);
			smp.DoOnItemDataBound (new SiteMapNodeItemEventArgs (i));
			Assert.AreEqual (true, ItemDataBounding, "AfterItemDataBound");

			ResetEvents ();
			SiteMapNodeItemEventArgs MyArgs = new SiteMapNodeItemEventArgs (new SiteMapNodeItem(0,SiteMapNodeItemType.Parent));
			Assert.AreEqual (false, ItemCreated, "BeforeItemCreated");
			smp.DoOnItemCteated (MyArgs);
			Assert.AreEqual (true, ItemCreated, "AfterItemCreated");
		}
Exemple #18
0
        protected virtual void InitializeItem(SiteMapNodeItem item)
        {
            ITemplate           nodeTemplate = null;
            Style               s            = null;
            SiteMapNodeItemType itemType     = item.ItemType;
            SiteMapNode         siteMapNode  = item.SiteMapNode;

            switch (itemType)
            {
            case SiteMapNodeItemType.Root:
                nodeTemplate = (this.RootNodeTemplate != null) ? this.RootNodeTemplate : this.NodeTemplate;
                s            = this._mergedRootNodeStyle;
                break;

            case SiteMapNodeItemType.Parent:
                nodeTemplate = this.NodeTemplate;
                s            = this._nodeStyle;
                break;

            case SiteMapNodeItemType.Current:
                nodeTemplate = (this.CurrentNodeTemplate != null) ? this.CurrentNodeTemplate : this.NodeTemplate;
                s            = this._mergedCurrentNodeStyle;
                break;

            case SiteMapNodeItemType.PathSeparator:
                nodeTemplate = this.PathSeparatorTemplate;
                s            = this._pathSeparatorStyle;
                break;
            }
            if (nodeTemplate == null)
            {
                if (itemType == SiteMapNodeItemType.PathSeparator)
                {
                    Literal child = new Literal {
                        Mode = LiteralMode.Encode,
                        Text = this.PathSeparator
                    };
                    item.Controls.Add(child);
                    item.ApplyStyle(s);
                }
                else if ((itemType == SiteMapNodeItemType.Current) && !this.RenderCurrentNodeAsLink)
                {
                    Literal literal2 = new Literal {
                        Mode = LiteralMode.Encode,
                        Text = siteMapNode.Title
                    };
                    item.Controls.Add(literal2);
                    item.ApplyStyle(s);
                }
                else
                {
                    HyperLink link = new HyperLink();
                    if ((s != null) && s.IsSet(0x2000))
                    {
                        link.Font.Underline = s.Font.Underline;
                    }
                    link.EnableTheming = false;
                    link.Enabled       = this.Enabled;
                    if (siteMapNode.Url.StartsWith(@"\\", StringComparison.Ordinal))
                    {
                        link.NavigateUrl = base.ResolveClientUrl(HttpUtility.UrlPathEncode(siteMapNode.Url));
                    }
                    else
                    {
                        link.NavigateUrl = (this.Context != null) ? this.Context.Response.ApplyAppPathModifier(base.ResolveClientUrl(HttpUtility.UrlPathEncode(siteMapNode.Url))) : siteMapNode.Url;
                    }
                    link.Text = HttpUtility.HtmlEncode(siteMapNode.Title);
                    if (this.ShowToolTips)
                    {
                        link.ToolTip = siteMapNode.Description;
                    }
                    item.Controls.Add(link);
                    link.ApplyStyle(s);
                }
            }
            else
            {
                nodeTemplate.InstantiateIn(item);
                item.ApplyStyle(s);
            }
        }
		WebControl CreateNodeControl (bool link, SiteMapNodeItem item)
		{
			if (link) {
				HyperLink h = new HyperLink ();
				h.Text = item.SiteMapNode.Title;
				h.NavigateUrl = item.SiteMapNode.Url;
				if (ShowToolTips)
					h.ToolTip = item.SiteMapNode.Description;
				return h;
			}
			else {
				Label h = new Label ();
				h.Text = item.SiteMapNode.Title;
				if (ShowToolTips)
					h.ToolTip = item.SiteMapNode.Description;
				return h;
			}
		}
Exemple #20
0
		protected virtual void CreateControlHierarchy ()
		{
			ArrayList nodes = new ArrayList ();
			SiteMapNode node = Provider.CurrentNode;
			if (node == null) return;
			
			int levels = ParentLevelsDisplayed != -1 ? ParentLevelsDisplayed + 1 : int.MaxValue;
			
			while (node != null && levels > 0) {
				if (nodes.Count > 0) {
					SiteMapNodeItem sep = new SiteMapNodeItem (nodes.Count, SiteMapNodeItemType.PathSeparator);
					InitializeItem (sep);
					SiteMapNodeItemEventArgs sargs = new SiteMapNodeItemEventArgs (sep);
					OnItemCreated (sargs);
					nodes.Add (sep);
				}

				SiteMapNodeItemType nt;
				if (nodes.Count == 0)
					nt = SiteMapNodeItemType.Current;
				else if (node.ParentNode == null)
					nt = SiteMapNodeItemType.Root;
				else
					nt = SiteMapNodeItemType.Parent;
					
				SiteMapNodeItem it = new SiteMapNodeItem (nodes.Count, nt);
				it.SiteMapNode = node;
				InitializeItem (it);
				
				SiteMapNodeItemEventArgs args = new SiteMapNodeItemEventArgs (it);
				OnItemCreated (args);
				
				nodes.Add (it);
				node = node.ParentNode;
				levels--;
			}
			
			if (PathDirection == PathDirection.RootToCurrent) {
				for (int n=nodes.Count - 1; n>=0; n--)
					Controls.Add ((Control)nodes[n]);
			} else {
				for (int n=0; n<nodes.Count; n++)
					Controls.Add ((Control)nodes[n]);
			}
		}
 public SiteMapNodeItemEventArgs(SiteMapNodeItem item)
 {
 }
		public void InitilizeItems (SiteMapNodeItem I)
		{
			InitializeItem (I);
		}
 protected virtual new void InitializeItem(SiteMapNodeItem item)
 {
 }
        protected virtual void CreateControlHierarchy()
        {
            ArrayList   nodes = new ArrayList();
            SiteMapNode node  = Provider.CurrentNode;

            if (node == null)
            {
                return;
            }

            int levels = ParentLevelsDisplayed != -1 ? ParentLevelsDisplayed + 1 : int.MaxValue;

            while (node != null && levels > 0)
            {
                if (nodes.Count > 0)
                {
                    SiteMapNodeItem sep = new SiteMapNodeItem(nodes.Count, SiteMapNodeItemType.PathSeparator);
                    InitializeItem(sep);
                    SiteMapNodeItemEventArgs sargs = new SiteMapNodeItemEventArgs(sep);
                    OnItemCreated(sargs);
                    nodes.Add(sep);
                }

                SiteMapNodeItemType nt;
                if (nodes.Count == 0)
                {
                    nt = SiteMapNodeItemType.Current;
                }
                else if (node.ParentNode == null)
                {
                    nt = SiteMapNodeItemType.Root;
                }
                else
                {
                    nt = SiteMapNodeItemType.Parent;
                }

                SiteMapNodeItem it = new SiteMapNodeItem(nodes.Count, nt);
                it.SiteMapNode = node;
                InitializeItem(it);

                SiteMapNodeItemEventArgs args = new SiteMapNodeItemEventArgs(it);
                OnItemCreated(args);

                nodes.Add(it);
                node = node.ParentNode;
                levels--;
            }

            if (PathDirection == PathDirection.RootToCurrent)
            {
                for (int n = nodes.Count - 1; n >= 0; n--)
                {
                    Controls.Add((Control)nodes[n]);
                }
            }
            else
            {
                for (int n = 0; n < nodes.Count; n++)
                {
                    Controls.Add((Control)nodes[n]);
                }
            }
        }
        protected virtual void InitializeItem(SiteMapNodeItem item)
        {
            switch (item.ItemType) {
                case SiteMapNodeItemType.Root:
                    if (RootNodeTemplate != null) {
                        item.ApplyStyle (NodeStyle);
                        item.ApplyStyle (RootNodeStyle);
                        RootNodeTemplate.InstantiateIn (item);
                    }
                    else if (NodeTemplate != null) {
                        item.ApplyStyle (NodeStyle);
                        item.ApplyStyle (RootNodeStyle);
                        NodeTemplate.InstantiateIn (item);
                    }
                    else {
                        WebControl c = CreateHyperLink (item);
                        c.ApplyStyle (NodeStyle);
                        c.ApplyStyle (RootNodeStyle);
                        item.Controls.Add (c);
                    }
                    break;

                case SiteMapNodeItemType.Current:
                    if (CurrentNodeTemplate != null) {
                        item.ApplyStyle (NodeStyle);
                        item.ApplyStyle (CurrentNodeStyle);
                        CurrentNodeTemplate.InstantiateIn (item);
                    }
                    else if (NodeTemplate != null) {
                        item.ApplyStyle (NodeStyle);
                        item.ApplyStyle (CurrentNodeStyle);
                        NodeTemplate.InstantiateIn (item);
                    } else if (RenderCurrentNodeAsLink) {
                        HyperLink c = CreateHyperLink (item);
                        c.ApplyStyle (NodeStyle);
                        c.ApplyStyle (CurrentNodeStyle);
                        item.Controls.Add (c);
                    } else {
                        Literal c = CreateLiteral (item);
                        item.ApplyStyle (NodeStyle);
                        item.ApplyStyle (CurrentNodeStyle);
                        item.Controls.Add (c);
                    }
                    break;

                case SiteMapNodeItemType.Parent:
                    if (NodeTemplate != null) {
                        item.ApplyStyle (NodeStyle);
                        NodeTemplate.InstantiateIn (item);
                    }
                    else {
                        WebControl c = CreateHyperLink (item);
                        c.ApplyStyle (NodeStyle);
                        item.Controls.Add (c);
                    }
                    break;

                case SiteMapNodeItemType.PathSeparator:
                    if (PathSeparatorTemplate != null) {
                        item.ApplyStyle (PathSeparatorStyle);
                        PathSeparatorTemplate.InstantiateIn (item);
                    }
                    else {
                        Literal h = new Literal ();
                        h.Text = PathSeparator;
                        item.ApplyStyle (PathSeparatorStyle);
                        item.Controls.Add (h);
                    }
                    break;
            }
        }
 HyperLink CreateHyperLink(SiteMapNodeItem item)
 {
     HyperLink h = new HyperLink ();
     h.Text = item.SiteMapNode.Title;
     h.NavigateUrl = item.SiteMapNode.Url;
     if (ShowToolTips)
         h.ToolTip = item.SiteMapNode.Description;
     return h;
 }
 Literal CreateLiteral(SiteMapNodeItem item)
 {
     Literal h = new Literal ();
     h.Text = item.SiteMapNode.Title;
     return h;
 }
 public SiteMapNodeItemEventArgs(SiteMapNodeItem item)
 {
     this._item = item;
 }
 public SiteMapNodeItemEventArgs(SiteMapNodeItem item)
 {
 }
        /// <devdoc>
        /// <para>A protected method. Populates iteratively the specified <see cref='System.Web.UI.WebControls.SiteMapNodeItem'/> with a
        ///    sub-hierarchy of child controls.</para>
        /// </devdoc>
        protected virtual void InitializeItem(SiteMapNodeItem item) {
            Debug.Assert(_mergedCurrentNodeStyle != null && _mergedRootNodeStyle != null);

            ITemplate template = null;
            Style style = null;
            SiteMapNodeItemType itemType = item.ItemType;
            SiteMapNode node = item.SiteMapNode;

            switch (itemType) {
                case SiteMapNodeItemType.Root:
                    template = RootNodeTemplate != null ? RootNodeTemplate : NodeTemplate;
                    style = _mergedRootNodeStyle;
                    break;

                case SiteMapNodeItemType.Parent:
                    template = NodeTemplate;
                    style = _nodeStyle;
                    break;

                case SiteMapNodeItemType.Current:
                    template = CurrentNodeTemplate != null ? CurrentNodeTemplate : NodeTemplate;
                    style = _mergedCurrentNodeStyle;
                    break;

                case SiteMapNodeItemType.PathSeparator:
                    template = PathSeparatorTemplate;
                    style = _pathSeparatorStyle;
                    break;
            }

            if (template == null) {
                if (itemType == SiteMapNodeItemType.PathSeparator) {
                    Literal separatorLiteral = new Literal();
                    separatorLiteral.Mode = LiteralMode.Encode;
                    separatorLiteral.Text = PathSeparator;
                    item.Controls.Add(separatorLiteral);
                    item.ApplyStyle(style);
                }
                else if (itemType == SiteMapNodeItemType.Current && !RenderCurrentNodeAsLink) {
                    Literal currentNodeLiteral = new Literal();
                    currentNodeLiteral.Mode = LiteralMode.Encode;
                    currentNodeLiteral.Text = node.Title;
                    item.Controls.Add(currentNodeLiteral);
                    item.ApplyStyle(style);
                }
                else {
                    HyperLink link = new HyperLink();

                    if (style != null && style.IsSet(System.Web.UI.WebControls.Style.PROP_FONT_UNDERLINE))
                        link.Font.Underline = style.Font.Underline;

                    link.EnableTheming = false;
                    link.Enabled = this.Enabled;
                    // VSWhidbey 281869 Don't modify input when url pointing to unc share
                    if (node.Url.StartsWith("\\\\", StringComparison.Ordinal)) {
                        link.NavigateUrl = ResolveClientUrl(HttpUtility.UrlPathEncode(node.Url));
                    }
                    else {
                        link.NavigateUrl = Context != null ?
                            Context.Response.ApplyAppPathModifier(ResolveClientUrl(HttpUtility.UrlPathEncode(node.Url))) : node.Url;
                    }
                    link.Text = HttpUtility.HtmlEncode(node.Title);
                    if (ShowToolTips)
                        link.ToolTip = node.Description;
                    item.Controls.Add(link);
                    link.ApplyStyle(style);
                }
            }
            else {
                template.InstantiateIn(item);
                item.ApplyStyle(style);
            }
        }
 private SiteMapNodeItem CreateItem(int itemIndex, SiteMapNodeItemType itemType, SiteMapNode node)
 {
     SiteMapNodeItem item = new SiteMapNodeItem(itemIndex, itemType);
     int index = (this.PathDirection == System.Web.UI.WebControls.PathDirection.CurrentToRoot) ? 0 : -1;
     SiteMapNodeItemEventArgs e = new SiteMapNodeItemEventArgs(item);
     item.SiteMapNode = node;
     this.InitializeItem(item);
     this.OnItemCreated(e);
     this.Controls.AddAt(index, item);
     item.DataBind();
     this.OnItemDataBound(e);
     item.SiteMapNode = null;
     item.EnableViewState = false;
     return item;
 }