Avoid current location highlight with sitemapdatasource

2 posts, 1 answers
  1. cprieto
    cprieto avatar
    7 posts
    Member since:
    Jul 2007

    Posted 10 Nov 2009 Link to this post

    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 title="Second item"
            <siteMapNode url="~/Page3.aspx" title="Page 3"  description="" /> 

    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"
        <asp:ContentPlaceHolder ID="head" runat="server"
        <form id="form1" runat="server"
        <telerik:RadScriptManager ID="RadScriptManager1" Runat="server"
        <telerik:RadMenu ID="RadMenu1" runat="server" Width="100%" DataSourceID="SiteMapDataSource1"
        <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" /> 
            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"

    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
  2. Answer
    Peter avatar
    6637 posts

    Posted 13 Nov 2009 Link to this post

    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;

    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.
Back to Top