Yug PR of Aspnet 3
Yug PR of Aspnet 3
ASP.Net
PRACTICAL:- 3
Aim:- Create Home page of your website using master page concept.
Theory:- Master pages are used to create consistency from page to page in a document.
Master pages typically contain page headers, footers, margin and column guides, and
other elements that occur on multiple pages in your document.
One of the key components to a successful Web site is a consistent look and feel.
In ASP.NET 1.x, developers used user controls to replicate common page elements
across a Web application is Master Page.
default.css Code:-
body {
margin: 0px;
font-family: Arial, Helvetica, sans-serif;
background-color: lightgrey;
}
main {
padding: 10px;
}
nav {
background-color: #808080;
padding: 5px;
}
ul {
list-style-type: none;
}
li a {
color: #F1FAEE;
font-size: 30px;
column-width: 10px;
}
li {
display: inline;
padding-left: 2px;
column-width: 20px;
}
a {
text-decoration: none;
margin-left: 20px
}
li a:hover {
background-color: #F3FFBD;
color: #FF1654;
}
footer {
background-color: #808080;
text-align: center;
color: white;
position: fixed;
bottom: 0px;
width: 100%;
padding: 20px;
margin: 5px auto 0 auto;
}
ASP.Net
MainSite Code:-
<html>
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head"
runat="server">
</asp:ContentPlaceHolder>
<link href="Styles/default.css"
rel="stylesheet" />
</head>
<body>
<form id="form1" runat="server">
<div>
<nav>
<ul>
<li><a
href="Default.aspx">Home</a></li>
<li><a
href="About.aspx">About</a></li>
<li><a
href="Contact.aspx">Contact</a></li>
</ul>
</nav>
<asp:ContentPlaceHolder
ID="ContentPlaceHolderMain" runat="server">
</asp:ContentPlaceHolder>
</div>
<footer>
<p>© 2024 Master Site @</p>
</footer>
</form>
</body>
</html>
ASP.Net
Default.aspx Code:-
<%@ Page Title="" Language="C#"
MasterPageFile="~/MainSite.Master"
AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="MasterPageDemo1.Default" %>
<asp:Content ID="Content3"
ContentPlaceHolderID="ContentPlaceHolderMain"
runat="server">
<main>
<h1>Welcome to my Main Site.</h1>
</main>
</asp:Content>
Contact.aspx Code:-
ASP.Net
About.aspx Code:-
</asp:Content>
Output:-
Header (Home) Section:-
ASP.Net
Header (Contact) Section:-
Conclusion:- In this Practical we have learn to make an header and footer section of a
website with the help of Master Page in Visual Studio Community.