Need a workaround for page group URL issue
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
>
protected
void
Page_Load(
object
sender, EventArgs e)
SiteMapDataSource1.StartingNodeUrl = StartingUrl;
RadSiteMap1.DataBind();
var selected = RadSiteMap1.SelectedNode;
if
(selected !=
null
)
selected.CssClass =
"active"
;
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"
;