More in this section

Forums / General Discussions / Internal Build: SiteMapPath and RadSiteMap not working?

Internal Build: SiteMapPath and RadSiteMap not working?

11 posts, 1 answered
  1. Gaston County
    Gaston County avatar
    38 posts
    Registered:
    23 Feb 2012
    18 Mar 2011
    Link to this post
    Basically what the title says. Anyone else experiencing this on Tuesday's internal build? My breadcrumb nav just disappeared. I tried to replace it with a RadSiteMap and it's empty too.
  2. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    22 Mar 2011
    Link to this post
    Hello Zak,

    As my collegue Ivan wrote in the other forum thread about the breadcrumbs, try using the following code workaround to fix the issue:

    1. Template

    <asp:SiteMapPath ID="SiteMapPath1" runat="server" RenderCurrentNodeAsLink="true" >
    <CurrentNodeTemplate>
    <asp:HyperLink runat="server" ID="CurrentNodeLink"></asp:HyperLink>
    </CurrentNodeTemplate>
    </asp:SiteMapPath>

    2. Code behind

    protected void Page_Load(object sender, EventArgs e)
    {
    this.SiteMapPath1.ItemCreated += new SiteMapNodeItemEventHandler(SiteMapPath1_ItemCreated);
    }
    void SiteMapPath1_ItemCreated(object sender, SiteMapNodeItemEventArgs e)
    {
    if (e.Item.ItemType == SiteMapNodeItemType.Current)
    {
    var currentNode = GetCurrentPageNode();
    var link = e.Item.FindControl("CurrentNodeLink") as HyperLink;
    link.Text = currentNode.UrlName;
    link.NavigateUrl = currentNode.UrlName;
    }
    }
    public static PageSiteNode GetCurrentPageNode()
    {
    PageSiteNode result = null;
    result = SiteMapBase.GetCurrentProvider().CurrentNode as PageSiteNode;
    if (result != null)
    {
    result = SiteMapBase.GetFirstPageDataNode(result);
    }
    return result;
    }


    Greetings,
    Victor Velev
    the Telerik team
  3. Gaston County
    Gaston County avatar
    38 posts
    Registered:
    23 Feb 2012
    22 Mar 2011
    Link to this post
    Victor,

    I copied your code into the control and still am getting nothing. The ItemCreated event doesn't seem to be being raised either.
  4. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    23 Mar 2011
    Link to this post
    Hello Zak,

    SiteMapPath appears not to function as it should in the latest internal build. I have logged it in TFS ( BUG ID = 111307 ).

    You will have to create a custom control for your breadcrumbs. Here is a quick workaround which you can modfiy so it suits your needs:

    1. Template:

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Bread.ascx.cs" Inherits="SitefinityWebApp.Templates.WebUserControl1" %>
    <asp:Repeater runat="server" ID="rep1">
     <ItemTemplate>
      <asp:HyperLink runat="server" ID="nodelink1" />
       <asp:Literal runat="server" ID="literalsep"></asp:Literal>
     </ItemTemplate>
    </asp:Repeater>

    2. The code behid:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Sitefinity.Web;
      
    namespace SitefinityWebApp.Templates
    {
        public partial class WebUserControl1 : System.Web.UI.UserControl
        {
      
      
            protected override void OnInit(EventArgs e)
            {
            }
      
      
            protected void Page_Load(object sender, EventArgs e)
            {
                var currentNode = SiteMapBase.GetActualCurrentNode();
                List<PageSiteNode> list = new List<PageSiteNode>();
                list.Add(currentNode);
                while (currentNode.ParentNode != null && currentNode.ParentNode.Title != "Pages")
                {
                    currentNode = currentNode.ParentNode as PageSiteNode;
                    list.Add(currentNode);
                }
      
                rep1.DataSource = list;
                rep1.ItemDataBound += new RepeaterItemEventHandler(rep1_ItemDataBound);
                rep1.DataBind();
      
            }
      
            void rep1_ItemDataBound(object sender, RepeaterItemEventArgs e)
            {
                if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
                {
                   var link = e.Item.FindControl("nodelink1") as HyperLink;
                   var l = e.Item.FindControl("literalsep") as Literal;
                   var node = e.Item.DataItem as PageSiteNode;
                   link.Text = node.Url;
                   link.NavigateUrl = node.Url;
                   if (l != null)
                   {
                       l.Text = ">";
                   }
                    
                }
            }
      
            
        }
    }


    All the best,
    Victor Velev
    the Telerik team
    Answered
  5. Dave
    Dave avatar
    16 posts
    Registered:
    10 Feb 2010
    30 Mar 2011
    Link to this post
    Since i had some Index issues i updated to the newest internal build too. Now my custom navigation control doesn't get any data. I suppose this is the same bug:

    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="true" StartingNodeOffset="1" />
    <asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" PathSeparator="/"
                    ShowExpandCollapse="False" PopulateNodesFromClient="false" OnDataBound="TreeView1DataBound"
                    OnTreeNodeDataBound="TreeView1TreeNodeDataBound">
    </asp:TreeView>

      Any updates on that? 
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    01 Apr 2011
    Link to this post
    Hello,

    If you subscribe for the events from the template, there should not be a problem. This works for SiteMapPath control. Can you put a breakpoint inside TreeView1TreeNodeDataBound and see if it is called?

    Greetings,
    Ivan Dimitrov
    the Telerik team
  7. Dave
    Dave avatar
    16 posts
    Registered:
    10 Feb 2010
    01 Apr 2011
    Link to this post
    Hi Ivan.

    I already had some code in the NodeDataBound Event. And it's not being called! 

    But why? :-)

    Regards

    Dave
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    06 Apr 2011
    Link to this post
    Hi,

    I added the following code in a user control


    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="true" />
    <asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" PathSeparator="/"
                    ShowExpandCollapse="False" PopulateNodesFromClient="false"
                    OnTreeNodeDataBound="TreeView1TreeNodeDataBound">
    </asp:TreeView>


    and the TreeView1TreeNodeDataBound is called. I tested with the latest internal build of Sitefinity 4.0.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

  9. Abraham
    Abraham avatar
    29 posts
    Registered:
    11 Aug 2010
    21 Apr 2011
    Link to this post
    This hit me also.  I submitted a support request to see if support can help me with a work around or something.  Is this problem in PITS so that I can vote for it?

  10. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    21 Apr 2011
    Link to this post
    Hello Abraham,

    I have logged it in PITS so you can vote for it and check its status at anytime.

    Greetings,
    Victor Velev
    the Telerik team

  11. tim
    tim avatar
    27 posts
    Registered:
    12 Oct 2010
    22 Jun 2011
    Link to this post
    FWIW... if like me you've been banging your head against a wall with constant

    error CS0103: The name 'rep1' does not exist in the current.....

    or with any other control for that matter that you trying to reference through a custom user control change:

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Yourcontrol.ascx.cs"

    to

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="Yourcontrol.ascx.cs"

    I'd forgotten about this little gem. VS doesnt like it and will complain but the control works fine, so for simplicity's sake, leave it as CodeBehind while building and then change it to CodeFile.

    eeeesh.
11 posts, 1 answered