1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Need a workaround for page group URL issue

Need a workaround for page group URL issue

2 posts, 0 answered
  1. Josh Anderson
    Josh Anderson avatar
    48 posts
    Registered:
    15 Dec 2005
    01 Mar 2011
    Link to this post
    I have a custom navigation control that applies a CSS class to the selected node, and I'm running into an issue with the selection getting applied when someone goes to the page group URL and is redirected to the first page's content. Because this redirection maintains the group URL and not the content page's URL, my control isn't correctly picking up the selection.

    Here's what I have in my ASCX file:
    <asp:SiteMapDataSource runat="server" ID="SiteMapDataSource1" ShowStartingNode="false" />
    <telerik:RadSiteMap runat="server" ID="RadSiteMap1" DataSourceID="SiteMapDataSource1" ></telerik:RadSiteMap>

    And in the codebehind:
    protected void Page_Load(object sender, EventArgs e)
    {
        SiteMapDataSource1.StartingNodeUrl = StartingUrl;
        RadSiteMap1.DataBind();
        var selected = RadSiteMap1.SelectedNode;
        if (selected != null)
            selected.CssClass = "active";
    }

    The StartingUrl property above is set when the control is used and is what restricts the navigation nodes that are displayed. The problem is that when a page group is clicked, the SelectedNode property doesn't show up in the list as it's the value of the StartingUrl.

    Is there a clean way to work around this? Or is this bug going to be addressed in the SP1 release coming out this week?

    Josh
  2. Josh Anderson
    Josh Anderson avatar
    48 posts
    Registered:
    15 Dec 2005
    01 Mar 2011
    Link to this post
    Answered my own question. This code appears to work:

    protected void Page_Load(object sender, EventArgs e)
    {
        SiteMapDataSource1.StartingNodeUrl = StartingUrl;
        RadSiteMap1.DataBind();
     
        var currentNode = SiteMapBase.GetActualCurrentNode(); // RadSiteMap1.SelectedNode;
        var selected = RadSiteMap1.Nodes.FindNodeByText(currentNode.Title);
        if (selected != null)
            selected.CssClass = "active";
    }
2 posts, 0 answered