More in this section

Forums / General Discussions / ASP SitemapPath Not rendering correctly

ASP SitemapPath Not rendering correctly

16 posts, 0 answered
  1. Michael
    Michael avatar
    59 posts
    Registered:
    02 Nov 2010
    02 Dec 2010
    Link to this post
    Since there is no longer a breadcrumb control in sitefinity 4.0  i made a quick custom control that is just has an asp sitemappath in it.  There are two issues i am running in to.

    1) no matter what the current node does not get rendered on the page.  I found that it is not putting anything between the <a></a> tags for the current node, the href part is rendered fine but there is no text

    2) In both firefox and safari the links are not clickable, IE is fine both 7 and 8.  I found this to be true in 3.7's breadcrumb control as well.

    Thx
    Michael
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    02 Dec 2010
    Link to this post
    Hello Michael,

    Can you try using this control

    <asp:SiteMapPath runat="server" ID="SiteMapPath1" RenderCurrentNodeAsLink="true" PathSeparator=">" ></asp:SiteMapPath>

    It is rendering the nodes as links at my end.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Michael
    Michael avatar
    59 posts
    Registered:
    02 Nov 2010
    02 Dec 2010
    Link to this post
    I tried it in a blank template, and it works to render the links as clickable, so i'm thinking i might have something off in my css for the masterpage.

    But i still have the problem of the Current Node Not Being Rendered.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    02 Dec 2010
    Link to this post
    Hi Michael,

    Can you show the code you use? My code above renders all nodes and includes the current one.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Michael
    Michael avatar
    59 posts
    Registered:
    02 Nov 2010
    02 Dec 2010
    Link to this post
    sure...  Mine has some custom stuff to it, but i tried it with the code you posted above and it behaves the same way for me. 

    i made a user control called Breadcrubs.ascx
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Breadcrumbs.ascx.cs" Inherits="SitefinityWebApp.Controls.Breadcrumbs" %>
     
    <asp:SiteMapPath runat="server" ID="SiteMapPath1" RenderCurrentNodeAsLink="true" PathSeparator=">" ></asp:SiteMapPath>


    code behind is
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
     
    namespace SitefinityWebApp.Controls
    {
        public partial class Breadcrumbs : System.Web.UI.UserControl
        {
            protected void Page_Load(object sender, EventArgs e)
            {
     
            }
            protected override void OnInit(EventArgs e)
            {
                base.OnInit(e);
                 SiteMapPath1.SkipLinkText = String.Empty;
                SiteMapPath1.ItemCreated += new SiteMapNodeItemEventHandler(Breadcrumb_ItemCreated);
            
                
            }
     
             
            protected void Breadcrumb_ItemCreated(object sender, SiteMapNodeItemEventArgs e)
            {
                //hide the root node, and it's following path separator
                 
                if (e.Item.ItemIndex == 0 | (e.Item.ItemIndex == 1 && e.Item.ItemType == SiteMapNodeItemType.PathSeparator))
                {
                    e.Item.Visible = false;
                }
                 
                 
            }
              
        }
    }

    then i added it as a control using these steps:
    http://www.sitefinity.com/40/help/developer-manual/controls-adding-a-new-control.html

    and then i add it to my template page.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    06 Dec 2010
    Link to this post
    Hello Michael,

    I checked the control with a local project and the current node was rendered correctly at my end. I do not see any problem with this code. There is some other logic that breaks it. Also, this is the standard ASP.NET SiteMapPath control which just added on a page ( without any server side code) displays all nodes properly.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Neil
    Neil avatar
    82 posts
    Registered:
    21 Oct 2006
    08 Dec 2010
    Link to this post
    Hi,

    Experiencing the same issues with current page not showing and also the root link reads Page not Home as expected.

    Regards,

    Neil
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    08 Dec 2010
    Link to this post
    Hello Neil,

    Pages is the StartingNode of the SiteMap. If you use the code above where Michael subscribes for Breadcrumb_ItemCreated, you cannot see Page, because it is explicitly hidden. I am sending you a short video. This is the standard ASP.NET control and of course there could be some improvements to it.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Neil
    Neil avatar
    82 posts
    Registered:
    21 Oct 2006
    08 Dec 2010
    Link to this post
    Thanks Ivan,

    I queried the breadcrumb in 3.7 and was pointed to adapters, the adapter implemented does not work in 4 and fails at collection.Add(node) value cannot be null.

    protected override void RenderContents(HtmlTextWriter writer)
    {
        writer.Indent++;
        SiteMapPath item = (SiteMapPath)Control;
        SiteMapProvider Provider = ((System.Web.UI.WebControls.SiteMapPath)(Control)).Provider;
        SiteMapNodeCollection collection = new SiteMapNodeCollection();
        SiteMapNode node = Provider.CurrentNode;
        if (node != null)
        {
            collection.Add(node);
            while (node != Provider.CurrentNode.RootNode)
            {
                node = node.ParentNode;
                collection.Add(node);
            }
        }
        BuildItems(collection, true, writer);
        writer.Indent--;
        writer.WriteLine();
    }

    [ArgumentNullException: Value cannot be null.
    Parameter name: value]
       System.Web.SiteMapNodeCollection.Add(SiteMapNode value) +2186483
       SitefinityWebApp.Widgets.Page.SiteMapPathAdapter.RenderContents(HtmlTextWriter writer) in C:\DEV\Coffey\Widgets\Page\SiteMapPathAdapter.cs:76
       System.Web.UI.WebControls.Adapters.WebControlAdapter.Render(HtmlTextWriter writer) +32
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +8863183
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +208
       System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
       System.Web.UI.Control.Render(HtmlTextWriter writer) +10
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +208
       System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
       System.Web.UI.Control.Render(HtmlTextWriter writer) +10
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +208
       System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +173
       System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +31
       System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +53
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
       System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +208
       System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
       System.Web.UI.Control.Render(HtmlTextWriter writer) +10
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +208
       System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
       Telerik.Web.UI.RadAjaxPage.Render(HtmlTextWriter writer) +55
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3060

    Regards,

    Neil
  10. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    10 Dec 2010
    Link to this post
    Hi Neil,

    It is failing at this line most probably:
    if (node != null)
    {
        collection.Add(node);
        while (node != Provider.CurrentNode.RootNode)
        {
            node = node.ParentNode;
            collection.Add(node);
        }
    }

    Please try getting the current node using the bellow code instead of the one you are currently using:
    SiteMapNode currentNode = SiteMapBase.GetCurrentProvider().CurrentNode;


    Greetings,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Ed Sirijintakarn
    Ed Sirijintakarn avatar
    19 posts
    Registered:
    02 Feb 2010
    11 Dec 2010
    Link to this post
    Hello,

    I'm also having the same problem where the current node is not being rendered.  On all pages and subpages, Telerik.Sitefinity.Web.PageSiteNode.Title is an empty string.

    As for setting the root node text to "Home", I'm reverting to:


    void smp_Breadcrumbs_ItemCreated(object sender, SiteMapNodeItemEventArgs e)
            {
                if ((e.Item.ItemType == SiteMapNodeItemType.Root) && (e.Item.Controls.Count > 0))
                {
                    if (e.Item.Controls[0] is HyperLink)
                    {
                        ((HyperLink)e.Item.Controls[0]).Text = "Home";
                    }
                }
            }

    I've searched around but couldn't find a way to set the sitemap root title via Sitefinity settings.  Did I miss something?

    Regards,
    Ed Sirijintakarn
    Internetiks, Inc.
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    13 Dec 2010
    Link to this post
    Hi Ed,

    You have to use an instance of PageNode which has a property Page.Title which is the name of the page.

    var pageNode = _SiteMapNode as PageSiteNode;
    var pn = man.GetPageNode(pageNode.Id);


    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  13. Ed Sirijintakarn
    Ed Sirijintakarn avatar
    19 posts
    Registered:
    02 Feb 2010
    13 Dec 2010
    Link to this post
    So, this is how I accomplished changing the root "Pages" text to "Home", in addition to rendering the current node...

    void smp_Breadcrumbs_ItemCreated(object sender, SiteMapNodeItemEventArgs e)
            {
                if ((e.Item.ItemIndex == 0) && (e.Item.ItemType == SiteMapNodeItemType.Root) && (e.Item.Controls.Count > 0))
                {
                    if (e.Item.Controls[0] is HyperLink)
                    {
                        ((HyperLink)e.Item.Controls[0]).Text = "Home";
                        ((HyperLink)e.Item.Controls[0]).ToolTip = "";
                    }
                }
                else if (e.Item.ItemType == SiteMapNodeItemType.Current)
                {
                    if (e.Item.Controls[0] is Literal)
                    {
                        Telerik.Sitefinity.Web.PageSiteNode pageSiteNode = (Telerik.Sitefinity.Web.PageSiteNode)e.Item.SiteMapNode;
                        Telerik.Sitefinity.Modules.Pages.PageManager manager = new Telerik.Sitefinity.Modules.Pages.PageManager();
      
                        Telerik.Sitefinity.Pages.Model.PageNode pageNode = manager.GetPageNode(pageSiteNode.Id);
      
                        ((Literal)e.Item.Controls[0]).Text = pageNode.Title.Value;
                    }
                }
            }

    Hopefully, there's a more efficient way to do this?

    Thanks,
    Ed Sirijintakarn
  14. Michael
    Michael avatar
    59 posts
    Registered:
    02 Nov 2010
    14 Dec 2010
    Link to this post
    thx ed.  That worked for me.  
  15. Philip Senechal
    Philip Senechal avatar
    69 posts
    Registered:
    07 Apr 2008
    21 Dec 2010
    Link to this post
    Does anyone else's Home link display twice when they are actually on the Home page using this code?

    I get a linked Home and then an unlinked Home...almost like it's not recognizing that it's at the root level.
  16. Rajesh
    Rajesh avatar
    13 posts
    Registered:
    11 Jan 2012
    31 Jan 2012
    Link to this post
    Hi
    I am getting Home twice..
    do you know how to fix it?
    Thanks,
16 posts, 0 answered