Need a workaround for page group URL issue

Posted by Community Admin on 03-Aug-2018 16:20

Need a workaround for page group URL issue

All Replies

Posted by Community Admin on 01-Mar-2011 00:00
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
Posted by Community Admin on 01-Mar-2011 00:00
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";
This thread is closed