Request a topic or
Contact an Arke consultant
404-812-3123
Creating a Horizontal Tabbed Menu with the Menu Control

Arke Systems Blog

Useful technical and business information straight from Arke.

About the author

Author Name is someone.
E-mail me Send mail

Recent comments

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2009

Creating a Horizontal Tabbed Menu with the Menu Control

I needed to create a quick horizontal tabbed menu with the Menu control.  The tabs have rounded corners so we're using image backgrounds.  We also have different images for the selected tab and when you hover.

image

<asp:Menu runat="server" ID="Menu1" SkinID="MenuHorizontalTabs">
    <Items>
        <asp:MenuItem Text="Tab 1" Value="Tab1" Selected="true" />
        <asp:MenuItem Text="Tab 2" Value="Tab2" />
        <asp:MenuItem Text="Tab 3" Value="Tab3" />
        <asp:MenuItem Text="Tab 4" Value="Tab4" />
    </Items>
</asp:Menu>

Then I added MenuHorizontalTabs to my skins file. 

<asp:Menu runat="server" SkinID="MenuHorizontalTabs" Orientation="Horizontal">
    <StaticItemTemplate>
        <div>
            <span>
                <asp:Literal runat="server" ID="Literal1" Text='<%# Eval("Text") %>' />
            </span>
        </div>
    </StaticItemTemplate>
    <StaticSelectedStyle CssClass="MenuHorizontalTabsSelectedMenuItem" />
    <StaticHoverStyle CssClass="MenuHorizontalTabsHoverMenuItem" />
    <StaticMenuItemStyle CssClass="MenuHorizontalTabsMenuItem" />
</asp:Menu>

Now, let's look at the CSS file.

.MenuHorizontalTabsMenuItem * div
{
    background:url(/images/header/left_both.gif) no-repeat left top; 
    height: 22px; 
    padding-left: 9px; 
    cursor: pointer;
}
.MenuHorizontalTabsMenuItem * span
{
    background:url(/images/header/right_both.gif) no-repeat right top; 
    padding: 5px 15px 4px 6px; 
    font-size: 10px; 
    color: #333; 
    height: 22px;
}
.MenuHorizontalTabsSelectedMenuItem * div
{
    background-position: 0px -150px;
}
.MenuHorizontalTabsSelectedMenuItem * span
{
    background-position: 0px -150px;
}
.MenuHorizontalTabsHoverMenuItem * div
{
    background-position: 0px -150px;
    color: Blue;
    text-decoration: none;
}
.MenuHorizontalTabsHoverMenuItem * span
{
    background-position: 0px -150px;
    color: Blue;
    text-decoration: none;
}

And finally, let's see the images.

left_both

left_both.gif

right_both

right_both.gif

Currently rated 3.3 by 3 people

  • Currently 3.333333/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: ASP.NET
Posted by eric stoll on Thursday, January 31, 2008 10:07 AM
Permalink | Comments (9) | Post RSSRSS comment feed

Related posts

Comments

andrew nz

Wednesday, June 25, 2008 10:41 PM

Great approach. But cd not make it work. Could u please attach source?

Hazar T Gupta in

Tuesday, July 01, 2008 2:24 AM

Greate Approch. But it is not working.
Could you please provide me source code.

Magnhild no

Wednesday, July 02, 2008 8:00 AM

You need to replace this line: background-position-y: -150px;
with this : background-position: 0px -150px;

Then it works fine Smile

And thank you for making my day!

Eric us

Wednesday, July 02, 2008 8:32 AM

Magnhild--Thanks for the suggestion. I have updated the article with your CSS.

Tippy us

Thursday, August 21, 2008 4:50 PM

I am new at building websites and am having trouble getting this code to work...probably because of my inexperience. I created a skin file called
MenuHorizontalTabs as shown above and also created a css file using the code above naming it MenuTabs.css. When I use the
SkinID="MenuHorizontalTabs" at asp:Menu of my default.aspx page, I get the error: A SkinID has been specified but the page is not configured
to use a page theme or stylesheet theme. If I take the SkinID= out and put Theme="MenuHorizontalTabs" in the page directive I just get the text for the
tabs but no images and no changes in the text when I hover with the mouse. How is the .css file used and should I have given it the same name
as the .skin file? Also, I am using VS 2005 and IE 6. I just cant get anything but the tab text to come up render. Thanks in advancde

Tempest gb

Monday, January 26, 2009 1:19 PM

Hi I came across this it it works absolutely great for me... one issue though.. I tested it on a MAC runnig safari and the tabs do not seem to work? anyone got any ideas why?

ta

pemenang pemilu 2009 us

Thursday, January 29, 2009 6:15 AM

nice tips, thank you for sharing. i'm gonna try it asap

Kampanye Damai Pemilu Indonesia 2009 ar

Sunday, February 01, 2009 5:08 PM

Thx for sharing and happy blogging

Kampanye Damai us

Tuesday, February 03, 2009 8:32 AM

i need the source code, don't you still have it?

Alda pt

Thursday, March 05, 2009 1:15 PM

I used the code, but it doesn't work. I used the first two blocks of code on my portal ascx file and the rest on my default.css file.
should it be working like this?

Thank you.

Make Money On The Internet us

Friday, May 01, 2009 1:16 AM

Enjoyed the source code.

tukang nggame

Sunday, May 03, 2009 4:56 AM

Nice code and info

free ebook us

Thursday, May 07, 2009 4:54 AM

I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.

Power Of Conversational Hypnosis us

Thursday, July 02, 2009 10:06 AM

Thank you, very good post

Add comment


 

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

Friday, July 03, 2009 9:15 PM