Menu Item Property


How can I change the property (color, ... ) of one single item of a manu (sub menu Items).


Best regards
4/30/2009 12:59:23 PM 13714 articles. 0 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 5

Hello There,

please take a look at this sample, hope this helps


<asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" 
      DynamicEnableDefaultPopOutImage="false" StaticEnableDefaultPopOutImage="false">
           <asp:MenuItem Text="Home" Value="Home"></asp:MenuItem>
           <asp:MenuItem Text="My Email" Value="MyEmail" NavigateUrl="~/Menus/HorizontalMenuandSubMenu.aspx" >
                 <asp:MenuItem Text ="Inbox" Value="Inbox"></asp:MenuItem>
                 <asp:MenuItem Text ="Sent" Value="sent"></asp:MenuItem>
                 <asp:MenuItem Text ="Trash" Value="Trash"></asp:MenuItem>
           <asp:MenuItem Text="Team 3P" Value="Team"></asp:MenuItem>

 and the code behind, i am doing on Page_Load event.

protected void Page_Load(object sender, EventArgs e)
        foreach (MenuItem menuitem in Menu1.Items)

            if (menuitem.Value == "MyEmail")
                // coloring the main menu item
                menuitem.Text = "<div style='color: Yellow'>" + menuitem.Text + "</div>";

            foreach (MenuItem submenuitem in menuitem.ChildItems)
                if (submenuitem.Value == "Inbox")
                    // coloring the sub menu item
                    submenuitem.Text = "<div style='color: Red'>" + submenuitem.Text + "</div>";



 I hope its gives you an idea.



Keyboard not found. Please Press < F1 > to RESUME

Please Remember to Mark as Answer for the post(s) that help it can help others......Thanks
4/30/2009 2:20:08 PM

Thanks for your help , but it doesn't work on my site caz I used XML (sitemap) for my menu and now I would like to have one of my sub menu items to appear in different color or the HOVER property would be different in one sub menu item.

Best regards
5/2/2009 5:01:42 PM


Make use of these properties 

<DynamicMenuItemStyle CssClass="DynamicMenuItemStyle" />..........This property will be effected on sub menus on normal position

<DynamicHoverStyle CssClass="DynamicMenuHover" /> ......This property will be effected on sub menus on hovering

CssClass is your style appliied to your menu or you can directly specify Css in the tag itself.

Hope it helps you.

Please Mark this "as answer" if it helps you.
5/4/2009 8:04:35 AM


  Define the following property.

        <asp:MenuItemStyle CssClass="sub_menu1" />
        <asp:MenuItemStyle CssClass="sub_menu2" />
        <asp:MenuItemStyle CssClass="sub_menu3" />
        <asp:MenuItemStyle CssClass="sub_menu4" />
        <asp:MenuItemStyle CssClass="sub_menu5" />
        <asp:MenuItemStyle CssClass="sub_menu6" />
        <asp:MenuItemStyle CssClass="sub_menu7" />

<DynamicHoverStyle CssClass="MRollover"/>
    <StaticHoverStyle CssClass ="MRollover" />

I have defined 7 menuitem styles. means it will gives 7 styles  menu, submenu,subsubmenu,....
and you can specify the rollover also.

R.charan kumar

Please mark the most helpful reply/replies as "Answer".
5/5/2009 5:14:57 AM

Similar Artilces:

Removing a menu item for the menu item control
In a menu control I have several items In the Menu1_Load event I want to conditionally remove a menu item.I use the codeMenu1.Items.RemoveAt(4). How do I test for the existence in the menu item at index 4 before removing it??Thanks Hi, You can compare Menu1.Items[4].Text against the title of the node. Yes but if it was removed earlier then the code will error out. So I need to test for the existence of Menu1.Items(4). If it exists then remove it. craigbtx: In a menu control I have several items In the Menu1_Load event I want to conditionally remove a menu item.I use the codeMe...

Menu Control
Hi everyone, Im developing an application in 2.0 by using menu control (in a user control).In which each menu item navigates to a new page. Now i want to apply different setting(For eg. Changes Forecolor) of selected Menu Item but the problem im facing is whenever i navigate to the new page the user control is reloaded and im unable to get the selected menu item. I can't use session or viewstate in my application. Thank u. Are you using MasterPage? If you put Menu control into the MasterPage and if the two content page you switches are both create from the same MasterPage,...

how to show the first menu item as the selected menu item in a "Menu control"
Hello Mate,    i have made a tab control using the menu control and the multi view control. all i need is, how can i show the first menu has been selected when my web page got run.   thanks in advance,Myself  Much Obliged & Thanks a Lot,Myself Sidewinder2: i have made a tab control using the menu control and the multi view control. all i need is, how can i show the first menu has been selected when my web page got run. Hi Sidewinder2, Why not use the Tabs control?  Also you can refer this link to solve your problem,

Button image for each top level menu item
For the subpage items I am just going to use background images/styles, but for the top level menu items, I have a button for each one. Just to complicate matters I have a rollover image for each, so when the user's mouse hovers over a given menu item, the button swaps out so they see a different color. Can I do images for the top level menu items? Are rollovers possible as well? How? Appreciate any input. I'm still trying to figure this one out. Has anyone used buttons for their top level menu items? If you could copy the info from your web.sitemap + the css file that would be most help...

Menu control
Hello everybody, I have the above problem. I have a menu on my master page that has four links. One of this links I want to be displayed only when the user is authenticated ( when the user is anonymous only 3 links should appear in the menu).  So, when the user is authenticated I tried to write something but it doesn't work. Here is the code: If User.Identity.IsAuthenticated ThenDim mymenu As New Menu mymenu = FindControl("menua") If Not IsNothing(mymenu) Then mymenu.Visible = False End If    The problem is that first I cannot find the way to make u...

Controlling how many menu items appear in the menu control
Hi I have a menu control which is bound to the web.sitemap. I want to be able to control how many static menu items can be displayed in the menu. I have the home button showing with other buttons too i.e. staticdisplaylevels=2. But how do I say for example to only show the first 6 main sitemap nodes to go in the menu so that there are only 6 menu items to chose from even though there are more defined in the sitemap. Thanks in advance. You can use the MenuItemDataBound event and hide the menu's you don't want to show to the user Alternatively you can add a custom attribute (visible="false"...

Retain state of controls on menu item click (Menu control)
I have a project setup as Master-Content pages. I have also included a Menu control in the master page. I have some textboxes and dropdownlists in content pages. The problem is that when I click any of the menu items, the page gets refreshed instead of doing a postback and all the values of the controls are gone. This creates a problem in a case where user is on one item page, he types in some values, does a postback, gets the results, and then if goes to other item in the menu and comes back, all those values are gone. How can I retain the values of controls (textboxes, dropdownl...

Why no visible property in Menu control items
Why is there no visible property in Menu control items? Dynamically creating menu's with controlled access to menu items is difficult to implement because of this limitation. Thanks,Jeff Wasilauski, MCAD .NET, MCPC# WEB DEVELOPMENT-SQL SERVER DBA"If I have answered your question please mark as answer" Yes, There is no visible property in Menu control items, but you can remove unwanted items in codebehind dynamically based on your needs. Menu1.Items.RemoveAt(index);  My Blog"Don't be afraid to be wrong; otherwise you'll never be right.&...

Causes validation Property not present in Menu Navigation control
I need to validate (client side validations using validation controls) my page on MenuItemClick, but CausesValidation property is not present for <asp:Menu> control.  Is there a work around for this, and what is the reason for Menu control not having this property? Hi, When you click on the menuItem, it will not postback on the page, but redirect to another page, so it has no CausesValidation property. But you can make a Validation in the codebehin:  the MenuItemClick event. If you find that when you click on the menuitem, it redirect to another page without p...

Menu control-highlight menu item
Hi, I have a menu control. If the user clicks for example menu item New user  and he is redirected to Default.aspx then i want the item New user   to be highlighted. I want the items of the menu to be highlighted according to what page the user is on.  <asp:menu id="NavigationMenu" runat="Server" staticdisplaylevels="2" orientation="Horizontal" width="100%" cssclass="font" backcolor="#B5C7DE" font-bold="True" font-names="Verdana" font-size="0.9em" font-strikeout="False" forecolor="#284E98" height="34px" dynamichorizontaloffset="2" staticsubmenuindent="10px"> &l...

Hideing menu item in menu control
Hai all in my application i am using Menu control.I am binding this menu with xml.i need to hide some of the menu in my menu control based on one flag in my xml string.From database i am taking that flag as a xml attribute in the same xml which i use to bind the menu.Plse Help meThanks in advanceLijo Rajan   hi , i dnt know how you maintain flags by using xml attributes, but i have found a good solution for creating dynamic menu by using menu control. go through this link, it may help you  Please: Don't forget to click "Mark as Answe...

Menu control menu items horizontally
how to show the menu items side by side horizontally when mouseover to  root Item in menu control, as we can set the orientation as horizontal in <asp:Menu></asp:Menu>,but how can we set the Orientation as horizontal to menu items <asp:MenuItem></asp:MenuItem>   example like About Us (Main Menu) login listings(these two options "login and listings" should displayed horizontall when mouseover on About Us link) its very urgent   Azam check Below url is it your looking.

How to make align of Menu Control items from Right to Left in .NET 2.0
Hai All I have a problem that on genertaing Dynamic Menu I want menu should generate from Right to Left Dynamic menu flow should have margin as Static Menu items Margin.   please solve my problem. Thank you   If you want the menu to be right-aligned, then you should use text-align: right in your CSS class. Example: <div style="text-align: right"> Short item<br/> A much longer item</br> Perhaps the longest item</br> </div> To get margins, you should use the margin attribute in CSS. Example: <div style="margin: 10px&q...

Menu Control: Adding pipes (|) in between menu items...?
I was just wondering if it was possible to insert pipes in my main (top level) menu items. Something like shown below: Home | Forums | Blogs | Respository | Search But I don't want these pipes to appear in the beginning or the end. I am not binding the menu to any datasource...programming blog I played around with a couple of ideas here.  Of course, I created a horizontal menu with static items.  Then in the designer, I tried to convert the items to a "static item template".  Within this, I added a '|' character after the text, but this still showed u...

image by side of menu item in menu control
I would like to add an image by the side of the my item in menu control. Is it programatically possible?    any help! I am using this menu control in the master page. I would like to prefix an image to the text of the menu item. inkrajesh:I would like to add an image by the side of the my item in menu control. Is it programatically possible?  Based on my experience, the MenuItem has a ImageUrl property, you can set image url to it to solve your problem, to know more, please check this link,

Web resources about - Menu Item Property -

Property - Wikipedia, the free encyclopedia
This article may require copy editing for grammar, style, cohesion, tone, or spelling . You can assist by editing it . In abstract, property ...

Property - Wikipedia, the free encyclopedia
In abstraction, property is that which belongs to or with something, whether as an attribute or as a component of said thing. For the significant ...

Chinese property firm Yuhu hires ex-deputy premier Andrew Stoner
A Chinese-based property firm that has donated hundreds of thousands of dollars to Australian political parties has added former deputy premier ...

How property developers make windfall millions
Buy one thing, use spin and insider knowledge to get planning approval to turn it into something completely different and, hey presto, you've ...

$1M transformation takes property from hoarding hell to heavenly home in Brisbane’s inner city - The ...
A HOARDER’s hovel has been transformed in seven months from a stinking mess to a dream family home — because of the efforts of two determined ...

Real estate: Couples opting for discount weddings to get a foot on property ladder
WHEN it comes to saving up for a home, life can get in the way.

Property estates on former Perth school sites popular with buyers - PerthNow Search Search
CRAIGIE, about 24km from the CBD, is the site of Perth’s latest residential school conversion. The first 22 blocks at the site of the former ...

Chinese property firm Yuhu hires ex-deputy premier Andrew Stoner
A Chinese-based property firm that has donated hundreds of thousands of dollars to Australian political parties has added former deputy premier ...

Esperance Bushfire: Reports of property losses as fires rage in south WA
Fast-moving, out-of-control bushfires threaten lives and homes in the Esperance region in southern Western Australia.

Seattle startup ranks every property in King County based on its redevelopment potential
... best properties to buy and what to build there. The 1-year-old company, Everyhome, already operates a website where buyers can bid on any property, ...

Resources last updated: 11/21/2015 1:56:37 PM