X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

ASP.NET Web Pages - Adding Navigation


Learn ASP.NET Web Pages by building a web site from scratch.

Part VI: Adding a Navigation Menu.


What We Will Do

In this chapter we will:

  • Add a navigation menu

Add a Navigation Menu

To add a navigation menu, edit your layout file (Layout.cshtml).

Put the following (red marked) code inside the layout file:

Layout.cshtml

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="Site.css">
</head>
<body>

<ul id="menu">
<li><a href="Default">Home</a></li>
<li><a href="About">About</a></li>
<li><a href="Customers">Data</a></li>
<li><a href="Register">Register</a></li>
<li><a href="Login">Login</a></li>
</ul>


<div id="main">
@RenderBody()
<p>&copy; 2013 W3Schools. All rights reserved.</p>
</div>

</body>
</html>

The layout file above, is a copy of the layout file from the previous chapter, with an added unordered list.


Edit The Style Sheet

Now, edit your style sheet (Site.css):

Put the following (red marked) code inside the file:

Site.css

body
{
font: "Trebuchet MS", Verdana, sans-serif;
background-color: #5c87b2;
color: #696969;
}
#main
{
padding: 30px;
background-color: #ffffff;
border-radius: 0 0 4px 4px;
}
h1
{
font: Georgia, serif;
border-bottom: 3px solid #cc9900;
color: #996600;
}

/* Forms */
fieldset label
{
display:block;
padding:4px;
}

input[type="text"],input[type="password"]
{
width:300px;
}

input[type="submit"]
{
padding:4px;
}

/* Menu */
ul#menu
{
padding: 0px;
position: relative;
margin: 0;
}

ul#menu li
{
display: inline;
}

ul#menu li a
{
background-color: #ffffff;
padding: 10px 20px;
text-decoration: none;
line-height: 2.8em;
color: #034af3;
border-radius: 4px 4px 0 0;
}

ul#menu li a:hover
{
background-color: #e8eef4;
}

Run example »

The style sheet above, is a copy of the style sheet from the previous chapter, with added styles for an unordered list (marked red), and a small change in the border-radius style for the main window.


Congratulations

You have added navigation to your website.



Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook