How to Create a Menu Web Page in VS2005
- 1). Open VS2005 and click "File" and then "New Website."
- 2). Select "ASP.NET Website" from the list that appears and click "Open" to create the project. VS2005 will create default template files and place them in the Solution Explorer on the right of the screen.
- 3). Double-click "Default.aspx." This file is located in the Solution Explorer. The file's C# code will appear in the code window.
- 1). Add the following code to the file's <form> tag:
<asp:Menu runat="server" BackColor="#FFFFFFF" ForeColor="#000000" Font-Names="Arial" >
This creates an ASP.NET menu. The values that you enter for background, foreground and font determine the appearance of those three properties on the menu. Change those values if you want to display different colors or fonts. - 2). Add this code below the previous code:
<asp:menuitem navigateurl="Entertainment.aspx" text="Entertainment">
This adds a menu item to the menu. Navigateurl defines the URL that the browser will open when a user clicks the menu item. - 3). Add this code below the previous code:
<asp:menuitem navigateurl="Movies.aspx" text="Movies" >
This adds a child menu item named "Movies" to the parent menu item named "Entertainment." When a user clicks this menu item, the browser will open the Movies.aspx URL. - 4). Add this code below the previous menu item:
<asp:menuitem navigateurl="ComedyMovies.aspx" text="Comedy Movies" />
This menu item is a child of "Movies," which is a child of "Entertainment." The "Comedy Movies" menu item will appear when a user moves the mouse over its parent menu item, "Movies." At this point, the hierarchical structure of the menu looks like this:
Entertainment
.... Movies
....... Comedy Movies
Add more types of movies if you like by adding more menu item tags below the "Movies" tag. All menu items will have "Movies" as a common parent. - 5). Add this block of code below the previous code:
<asp:menuitem navigateurl="Music.aspx" text="Music">
<asp:menuitem navigateurl="Blues.aspx" text="Blues" />
<asp:menuitem navigateurl="Rock.aspx" text="Rock" />
</asp:menuitem>
This adds a "Music" category to the menu. Its child categories are "Blues" and "Rock." The menu structure now looks like this:
Entertainment
.... Movies
........ Comedy Movies
..... Music
......... Folk
......... Rock
Whenever a user moves the mouse over a parent menu item, all child menu items will appear. This is how all hierarchical menu items work. - 6). Press "F5" to view the web page in your browser. Move the mouse over the parent items and verify that the child items appear.
Create Web Project
Add Menu
Source...