Yug PR of Aspnet 4
Yug PR of Aspnet 4
ASP.Net
PRACTICAL:- 4
Aim:- Create a simple web application to illustrate the concept of nesting master page
in ASP.NET
Theory:- Master pages can be nested, with one master page referencing another as its
master. Nested master pages allow you to create componentized master pages.
A nested page template is a page template that is based on an existing page template
(also known as the root template). Nested page templates give you more flexibility
in Web sites that have both static pages and dynamic pages.
style.css Code:-
/* General Styles */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
color: #333;
}
/* Header Styles */
header {
background-color: #007bff;
color: white;
padding: 20px 0;
text-align: center;
}
header h1 {
margin: 0;
font-size: 2em;
}
/* Navigation Styles */
nav {
background-color: #0056b3;
}
nav ul {
list-style: none;
padding: 0;
margin: 0;
display: flex;
justify-content: center;
}
nav ul li {
margin: 0;
}
nav ul li a {
display: block;
padding: 15px 20px;
color: white;
text-decoration: none;
transition: background-color0.3s;
}
nav ul li a:hover {
background-color: #003d7a;
}
ASP.Net
Site.Master Code:-
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs"
Inherits="NestedMasterPageDemo.Site" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Site Master</title>
<link href="Styles/style.css" rel="stylesheet" />
</head>
<body>
<form id="form1" runat="server">
<div>
<header>
<h1>My Website(Grand Father)</h1>
<nav>
<ul>
<li><a href="Default.aspx">Home</a></li>
<li><a href="About.aspx">About</a></li>
</ul>
</nav>
</header>
<asp:ContentPlaceHolder id="MainContent" runat="server">
</asp:ContentPlaceHolder>
<footer>
<p>© 2024 My Website</p>
</footer>
</div>
</form>
</body> </html>
ASP.Net
Nested.Master Code:-
<asp:Content ID="Content1"
ContentPlaceHolderID="MainContent" runat="server">
<h2>Nested Master Page Content (Father)</h2>
<asp:ContentPlaceHolder ID="NestedContent"
runat="server">
</asp:ContentPlaceHolder>
</asp:Content>
Default.aspx Code:-
</asp:Content>
About.aspx Code:-
ASP.Net
Output:- Header(Home) section:-
Header(About) section:-
Conclusion:- In this Practical we have learn to make an header and footer section and we
add some sections like (Father & Son) so that we can add some details of a website with
the help of Nested Master Page in Visual Studio Community.