Professional Documents
Culture Documents
Advance Web Application Development: Instructor: Dr. Syed Ali Raza Department of Computer Science GC University Lahore
Advance Web Application Development: Instructor: Dr. Syed Ali Raza Department of Computer Science GC University Lahore
Development
Instructor: Dr. Syed Ali Raza
Department of Computer Science
GC University Lahore
Lecture 9
Layouts
Give someone a program, you frustrate them for a day;
teach them how to program, you frustrate them for a
lifetime.
— David Leinweber
Layouts
• On the Internet you will discover many web sites with a consistent
look and feel:
• Every page have the same header
• Every page have the same footer
• Every page have the same style and layout
Using Layout Page
<html>
<head>
<title> @ViewBag.Title</title>
</head>
<body>
<table border =1 style=”width800px; font-family:arial”>
<tr> <td colspan=”2” style=”text-align:center”><h3>website header</h3></td> </tr>
<tr> <td style=”width:200px”><h3>Menu</h3></td>
<td style=”width:600px”> @RenderBody()</td> </tr>
<tr>
<td colspan=”2” style=”text-align:center; font-size:x-small”><h3>website
Footer</h3></td>
</tr>
</table>
</body>
</html>
Updated Layout with Style Sheets and HTML
Helpers
<!DOCTYPE html>
<html>
<head> <title> @ViewBag.Title - in ASP.Net MVC</title> <link href="@Url.Content("~/Content/MyCSS.css")" rel="stylesheet"
type="text/css" /> </head>
<body> <table border=1 style="width:800px;" align="center">
<tr> <td colspan="2" style="text-align:center"> <img src="@Url.Content("~/images/header.jpg")" height="90" width="750" />
</td> </tr>
<tr>
<td style="width:200px">
<ul id="menu">
<li>
@Html.ActionLink("Home", "Index") </li>
<li>
@Html.ActionLink("About", "About")</li>
</ul>
</td>
<td style="width:600px"> @RenderBody()</td>
</tr>
<tr> <td colspan="2" style="text-align:center; font-size:x-small"> <div><h3>Copyrights © 2019. All rights reserved for University of
Education </h3></div>
</td>
</tr>
</table>
</body>
</html>
Url.Content()
ul#menu {
position:relative;
margin: 0; }
ul#menu li {
display: block;
align-items:center; }
ul#menu li a {
background-color: #e8eef4;
padding: 10px 20px;
line-height: 2.8em;
border-radius: 4px 4px 0 0; }
ul#menu li a:hover {
background-color: #b200ff; }
Updated Layout with Style Sheets and HTML
Helpers
<!DOCTYPE html>
<html>
<head> <title> @ViewBag.Title - in ASP.Net MVC</title> <link href="@Url.Content("~/Content/MyCSS.css")" rel="stylesheet" type="text/css" />
</head>
<body> <table border=1 style="width:800px;" align="center">
<tr> <td colspan="2" style="text-align:center"> <img src="@Url.Content("~/images/header.jpg")" height="90"
width="750" /> </td> </tr>
<tr>
<td style="width:200px">
<ul id="menu">
<li>
@Html.ActionLink("Home", "Index") </li>
<li>
@Html.ActionLink("About", "About")</li>
</ul>
</td>
<td style="width:600px"> @RenderBody()</td>
</tr>
<tr> <td colspan="2" style="text-align:center; font-size:x-small"> <div><h3>Copyrights © 2018. All rights reserved for University of
Education </h3></div>
</td>
</tr>
</table>
</body>
</html>
Inserting Images
Updated Layout with Style Sheets and HTML
Helpers
<!DOCTYPE html>
<html>
<head> <title> @ViewBag.Title - in ASP.Net MVC</title> <link href="@Url.Content("~/Content/MyCSS.css")" rel="stylesheet" type="text/css" />
</head>
<body> <table border=1 style="width:800px;" align="center">
<tr> <td colspan="2" style="text-align:center"> <img src="@Url.Content("~/images/header.jpg")" height="90" width="750" />
</td> </tr>
<tr>
<td style="width:200px">
<ul id="menu">
<li>
@Html.ActionLink("Home", "Index") </li>
<li>
@Html.ActionLink("About", "About")</li>
</ul>
</td>
<td style="width:600px"> @RenderBody()</td>
</tr>
<tr> <td colspan="2" style="text-align:center; font-size:x-small"> <div><h3>Copyrights © 2018. All rights reserved for University of
Education </h3></div>
</td>
</tr>
</table>
</body>
</html>
HTML.Action Link