This is a migrated thread and some comments may be shown as answers.

Avoid current location highlight with sitemapdatasource

1 Answer 71 Views
Menu
This is a migrated thread and some comments may be shown as answers.
cprieto
Top achievements
Rank 1
cprieto asked on 10 Nov 2009, 06:35 PM
I have a simple site map file:
<?xml version="1.0" encoding="utf-8" ?> 
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" > 
    <siteMapNode url="" title=""  description=""
      <siteMapNode title="First item"
        <siteMapNode url="~/Page1.aspx" title="Page 1"  description="" /> 
        <siteMapNode url="~/Page2.aspx" title="Page 2"  description="" /> 
      </siteMapNode> 
      <siteMapNode title="Second item"
        <siteMapNode url="~/Page3.aspx" title="Page 3"  description="" /> 
      </siteMapNode> 
    </siteMapNode> 
</siteMap> 
 


A simple sitemap data source is added to the page

A radmenu is binded to that data source...

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="WebApplication1.Site" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"
    <title></title
    <asp:ContentPlaceHolder ID="head" runat="server"
    </asp:ContentPlaceHolder> 
</head> 
<body> 
    <form id="form1" runat="server"
    <telerik:RadScriptManager ID="RadScriptManager1" Runat="server"
    </telerik:RadScriptManager> 
    <telerik:RadMenu ID="RadMenu1" runat="server" Width="100%" DataSourceID="SiteMapDataSource1"
    </telerik:RadMenu> 
    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" /> 
    <div> 
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"
         
        </asp:ContentPlaceHolder> 
    </div> 
    </form> 
</body> 
</html> 
 


now, everytime I go to Page1.aspx the "First Time" and "Page 1" node in my radmenu are highlighted (as expected) because that is the current location returned by the sitemapdatasource1

How could I avoid this behaivor? I don't want to highlight the current page in the radmenu, I guess this should be something I just don't know how to do...

Could somebody help me please?

PD: ASP.NET RadControls 2009 Q2

1 Answer, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 13 Nov 2009, 03:00 PM
Hello Cristian,

You can easily disable this feature by handling RadMenu's DataBound event as follows:

protected void RadMenu1_DataBound(object sender, EventArgs e)
   {
       foreach (RadMenuItem item in RadMenu1.GetAllItems())
       {
           item.CssClass = String.Empty;
       }
   }



Greetings,
Peter
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Menu
Asked by
cprieto
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or