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

Root Menu background color

3 Answers 134 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Patxi
Top achievements
Rank 1
Patxi asked on 12 Mar 2009, 12:45 PM
Hi,

how can I change background color to root menu when an item is selected?Using skin file.

I have tried everything but there´s no way!

thank you in advance.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 12 Mar 2009, 02:11 PM
Hi Patxi,

I guess you want to set the colour of selected item like RadMenuRootitem. Try the following code and check whether it suits your need.

CS:
protected void RadMenu1_ItemClick(object sender, Telerik.Web.UI.RadMenuEventArgs e)  
{  
    RadMenuItem selItem = (RadMenuItem)e.Item;          
    foreach (RadMenuItem item in RadMenu1.GetAllItems())  
    {  
        if (item == selItem )  
        {  
           item.CssClass = "MyClass";  
        }  
        else 
        {  
            item.CssClass = "";  
        }  
    }    

CSS:
<style type="text/css">  
.MyClass  
{  
    background-color: Gray !important;  
}  
</style> 
Note: Change the color according to the skin that you are using, if any.

Thanks,
Princy.
0
Patxi
Top achievements
Rank 1
answered on 13 Mar 2009, 09:16 AM
Thank you Princy.

I have checked your code and I don´t know why is not jumping to the event.
I have this code:
     <telerik:RadMenu ID="mnuAplicacion" runat="server" EnableEmbeddedSkins="false" Skin=""  OnItemClick="RadMenu1_ItemClick">

But when clicking is not jumping to the function, don´t know the reason.
any idea?
0
Patxi
Top achievements
Rank 1
answered on 20 Mar 2009, 02:00 PM
Hello,

I write again to tell that I didn´t get what I wanted.

I have implemented the following code:

<telerik:RadMenu ID="mnuAplicacion"  runat="server" EnableEmbeddedSkins="false" Skin="OT" Style="z-index: 2000" OnItemClick="RadMenu1_ItemClick" OnItemDataBound="RadMenu1_ItemDataBound"


       protected void Page_Load(object sender, EventArgs 
       { 
            string item = Server.UrlDecode(Request["Item"]); 
            if (!string.IsNullOrEmpty(item)) 
            { 
                RadMenuItem currentItem = mnuAplicacion.FindItemByText(item); 
                if (currentItem != null
                { 
                    //currentItem.HighlightPath(); 
                    currentItem.CssClass = "cambioFondo"
                } 
            } 
        } 
         
        protected void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e) 
        { 
            e.Item.Attributes["NavigateUrl"] = e.Item.NavigateUrl; 
            e.Item.NavigateUrl = ""
        } 
 
        protected void RadMenu1_ItemClick(object sender, RadMenuEventArgs e) 
        { 
            //Custom code here        
 
            //Navigate      
            Response.Redirect(e.Item.Attributes["NavigateUrl"].ToString()); 
        } 

But it is not executing RadMenu1_ItemDataBound function.

Do you know why?I need to get to be executed.

Thank you in advance.





Tags
Menu
Asked by
Patxi
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Patxi
Top achievements
Rank 1
Share this question
or