Click here to Skip to main content
13,087,566 members (93,266 online)
Click here to Skip to main content
Add your own
alternative version


65 bookmarked
Posted 13 Jun 2004

One-Level ASP.NET Menu – FlatMenu

, 16 Jun 2004
Rate this:
Please Sign up or sign in to vote.
Simple navigation menu bar with CSS, PostBack and other features


The simple menu can be applied foremost to navigate among several web forms. Features of the FlatMenu:

  1. One-Level menu only (no popup submenus).
  2. Rendering brief HTML code into div and span (no table tr td).
  3. Possibility to invocate of PostBack for each single menu item.
  4. No extra worthless JavaScript (except of PostBack sure).
  5. Distinguished menu item of the just loaded web form.
  6. Simple, well-arranged XML file data source in one place.
  7. Horizontal and vertical layout option.
On-line presentation is available at [^]


The control is based on the Scott Mitchell's excellent piece of software skmMenu.

Using the code

Data binding

In the Page_Load method of the Web Form

flatMenu.DataSource = Server.MapPath("FlatMenu.xml");

or caching menu to avoid access to file system by every request: in Application_Start (Global.asax.cs)

XmlDocument xmlMenu = new XmlDocument();
Application["flatMenu"] = xmlMenu;

and again the method Page_Load

flatMenu.DataSource = Application["flatMenu"];

XML data source

Example of the structure of the XML file:

    <item postback="true">
            web form
    <item suppresspostback="true">
            other web form
            CodeProject site

Attribute postback means click on this menu item raises the postback. When active (current loaded) menu item has attribute supresspostback="true" then every other menu items behave as common a tag, so no postback raises.

Active menu item

The HTML tag belong to menu item of just loaded web form has this class attribute:

span class="activeHoriz", for horizontal menu layout
div class="activeVert", for vertical menu layout

CSS design

For customize design by CSS is important how the menu is rendered into the HTML code.

Horizontal rendering:

<div id="idFlatMenu">
    <span class="activeHoriz"></span>

Vertical rendering:

<div id="idFlatMenu">
    <div class="activeVert"></span>


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Petr Felzmann
Web Developer
Czech Republic Czech Republic
No Biography provided

You may also be interested in...

Comments and Discussions

Generalgood ! Pin
1hello227-Aug-08 20:51
member1hello227-Aug-08 20:51 
Questionhow the control will rendered Pin
mbbisht24-Aug-07 0:26
membermbbisht24-Aug-07 0:26 
GeneralPassing aguments to the hyperlinks Pin
Miszou7-Dec-04 11:25
memberMiszou7-Dec-04 11:25 
GeneralWould be good if it worked in ... Pin
Anonymous16-Jun-04 2:59
sussAnonymous16-Jun-04 2:59 
GeneralRe: Would be good if it worked in ... Pin
Petr Felzmann16-Jun-04 18:48
memberPetr Felzmann16-Jun-04 18:48 
GeneralCould be really good... Pin
Joel Holdsworth14-Jun-04 1:39
memberJoel Holdsworth14-Jun-04 1:39 
GeneralRe: Could be really good... Pin
Petr Felzmann14-Jun-04 1:54
memberPetr Felzmann14-Jun-04 1:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170813.1 | Last Updated 17 Jun 2004
Article Copyright 2004 by Petr Felzmann
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid