We know that ASP.NET 2.0 has introduced the Masterpages.
but some us might be thinking is there any way to do this in ASP.NET 1.1.
ASP.NET 1.1 doesnot directly supports it. But you can do it using Spring.NET Web Application Framwork. The Spring.Web framework provides a nice set of features through which we can enable master page support in ASP.NET 1.1 applications.
The best link you can look in is (Chapter 22.6. Support for ASP.NET 1.1 master pages in Spring.Web)
A sample master page (MasterLayout.ascx) – A User Control could look like this:
[code lang=”html”]
<%@ Control language="c#" Codebehind="MasterLayout.ascx.cs" AutoEventWireup="false" Inherits="MyApp.Web.UI.MasterLyout" %>
<%@ Register TagPrefix="spring" Namespace="Spring.Web.UI.Controls" Assembly="Spring.Web" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" &gt;
<html>
<head>
<title>Master Page</title>
<link rel="stylesheet" type="text/css" href="<%= Context.Request.ApplicationPath %>/css/styles.css">
<spring:ContentPlaceHolder id="head" runat="server"/>
</head>
<body>
<form runat="server">
<table cellPadding="3" width="100%" border="1">
<tr>
<td colspan="2>
<spring:ContentPlaceHolder id="title" runat="server">
<!– default title content –>
</spring:ContentPlaceHolder>
</td>
</tr>
<tr>
<td>
<spring:ContentPlaceHolder id="leftSidebar" runat="server">
<!– default left side content –>
</spring:ContentPlaceHolder>
</td>
<td>
<spring:ContentPlaceHolder id="main" runat="server">
<!– default main area content –>
</spring:ContentPlaceHolder>
</td>
</tr>
</table>
</form>
</body>
</html>
[/code]
We can have an ASPX page that uses this master page (Child.aspx) might look like this:
[code lang=”html”]
<%@ Register TagPrefix="spring" Namespace="Spring.Web.UI.Controls" Assembly="Spring.Web" %>
<%@ Page language="c#" Codebehind="Child.aspx.cs" AutoEventWireup="false" Inherits="ArtFair.Web.UI.Forms.Child" %>
<html>
<body>
<spring:Content id="leftSidebarContent" contentPlaceholderId="leftSidebar" runat="server"&>
<!– left sidebar content –>
</spring:Content>
<spring:Content id="mainContent" contentPlaceholderId="main" runat="server">
<!– main area content –>
</spring:Content>
</body>
</html>
[/code]
The &
control in the example uses the contentPlaceholderId
attribute (property) to specify exactly which placeholder from the master page is to be overridden. Because this particular page does not define content elements for the head and title placeholders, the content elements are defined by the default content supplied in the master page.
Both the ContentPlaceHolder
and Content
controls can contain any valid ASP.NET markup: HTML, standard ASP.NET controls, user controls, and so on.
Cool right!!!. Hope this helps. Happy Coding Guys!!. You might wonder, is any one still using asp.net 1.1? Ya, It’s the very basic ASP.NET 1.1, you can learn about .NET 1.1 from the scratch. I love using .NET 1.1
Discover more from Cloud Distilled ~ Nithin Mohan
Subscribe to get the latest posts sent to your email.
[…] This post was mentioned on Twitter by Nithin Mohan T K. Nithin Mohan T K said: Master Page Support in ASP.NET 1.1: We know that ASP.NET 2.0 has introduced the Masterpages. but some us might be … http://bit.ly/b7A7gb […]