473,398 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

master pages - header, content, footer

Thinking of creating a website, most of the pages will have a general
toolbar
menu, a content and a footer.
The content will be the only one who's gonna change but the rest
(header,footer)
will remain the same.
I am interested to know your opinions/suggestions in finding an easy
way of doing it.

In asp one could have something like this:
let's say we have a page x1_page.asp

<!--#include file="top.asp"-->
<!--#include file="x1_content.asp"-->
<!--#include file="footer.asp"-->

Put it more simple for x2_page.asp I will only change the content
inclusion:

<!--#include file="top.asp"-->
<!--#include file="x2_content.asp"-->
<!--#include file="footer.asp"-->

and I don't have to change anything on top and footer.
In ASP.net 2.0 is any way to accomplish the same, or to create a
wrapper with master pages? Do you have any other ideas? PlaceHolder
maybe one even though it's
not very stright and simple.

Thanks,
XK

Jul 24 '06 #1
7 8679
This is exactly what master pages are for and most of the getting started
examples you will find on the web are pretty much representitive of the type
of site you would like to put together.

Regards

John Timney (MVP)

<xk****@gmail.comwrote in message
news:11*********************@75g2000cwc.googlegrou ps.com...
Thinking of creating a website, most of the pages will have a general
toolbar
menu, a content and a footer.
The content will be the only one who's gonna change but the rest
(header,footer)
will remain the same.
I am interested to know your opinions/suggestions in finding an easy
way of doing it.

In asp one could have something like this:
let's say we have a page x1_page.asp

<!--#include file="top.asp"-->
<!--#include file="x1_content.asp"-->
<!--#include file="footer.asp"-->

Put it more simple for x2_page.asp I will only change the content
inclusion:

<!--#include file="top.asp"-->
<!--#include file="x2_content.asp"-->
<!--#include file="footer.asp"-->

and I don't have to change anything on top and footer.
In ASP.net 2.0 is any way to accomplish the same, or to create a
wrapper with master pages? Do you have any other ideas? PlaceHolder
maybe one even though it's
not very stright and simple.

Thanks,
XK

Jul 24 '06 #2
John, thanks for answering.
With Master Pages it's exactly what I thought at the beginning but
getting to the code part I got stuck when I had to write the content.

Let me explain, I am sure I am missing something, but I don't know
what. So if I have a master page like this:

<%@ Master Language="VB" CodeFile="MasterPage.master.vb"
Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server" <title>Untitled Page</title</head>
<body>
<form id="form1" runat="server">
<table width="100%">
<tr>
<td>
<asp:contentplaceholder id="ContentHeader" runat="server">
</asp:contentplaceholder>
</td>
</tr>
<tr>
<td>
<asp:contentplaceholder id="ContentPlaceHolder" runat="server">
</asp:contentplaceholder>
</td>
</tr>
<tr>
<td>
<asp:contentplaceholder id="ContentFooter" runat="server">
</asp:contentplaceholder>
</td>
</tr>
</table>
</form>
</body>
</html>

I end up having just ONE file for the content page:

<%@ Page Language="VB" MasterPageFile="~/template/MasterPage.master"
AutoEventWireup="false" CodeFile="Default2.aspx.vb"
Inherits="template_Default2" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentHeader"
Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder"
Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentFooter"
Runat="Server">
</asp:Content>
My problem is: I want to have 3 different independent files:
header.aspx, content.aspx and footer.aspx so at the end (after creating
header and footer) I will only write content part.

Otherwise am I going to write Content1 and Content3 everytime when I
create a new page??

Thanks again,
XK

John Timney (MVP) wrote:
This is exactly what master pages are for and most of the getting started
examples you will find on the web are pretty much representitive of the type
of site you would like to put together.

Regards

John Timney (MVP)

<xk****@gmail.comwrote in message
news:11*********************@75g2000cwc.googlegrou ps.com...
Thinking of creating a website, most of the pages will have a general
toolbar
menu, a content and a footer.
The content will be the only one who's gonna change but the rest
(header,footer)
will remain the same.
I am interested to know your opinions/suggestions in finding an easy
way of doing it.

In asp one could have something like this:
let's say we have a page x1_page.asp

<!--#include file="top.asp"-->
<!--#include file="x1_content.asp"-->
<!--#include file="footer.asp"-->

Put it more simple for x2_page.asp I will only change the content
inclusion:

<!--#include file="top.asp"-->
<!--#include file="x2_content.asp"-->
<!--#include file="footer.asp"-->

and I don't have to change anything on top and footer.
In ASP.net 2.0 is any way to accomplish the same, or to create a
wrapper with master pages? Do you have any other ideas? PlaceHolder
maybe one even though it's
not very stright and simple.

Thanks,
XK
Jul 24 '06 #3
XK-

It is possible to have "nested" masterpages, although it is not
literally one masterpage file within another. I dont use this system
really as it seems to be pretty cumbersome.

Check out www.asp.net for tutorial videos (I found them really useful)
on masterpages in general.

Hope the videos help,

Chris

xk****@gmail.com wrote:
John, thanks for answering.
With Master Pages it's exactly what I thought at the beginning but
getting to the code part I got stuck when I had to write the content.

Let me explain, I am sure I am missing something, but I don't know
what. So if I have a master page like this:

<%@ Master Language="VB" CodeFile="MasterPage.master.vb"
Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server" <title>Untitled Page</title</head>
<body>
<form id="form1" runat="server">
<table width="100%">
<tr>
<td>
<asp:contentplaceholder id="ContentHeader" runat="server">
</asp:contentplaceholder>
</td>
</tr>
<tr>
<td>
<asp:contentplaceholder id="ContentPlaceHolder" runat="server">
</asp:contentplaceholder>
</td>
</tr>
<tr>
<td>
<asp:contentplaceholder id="ContentFooter" runat="server">
</asp:contentplaceholder>
</td>
</tr>
</table>
</form>
</body>
</html>

I end up having just ONE file for the content page:

<%@ Page Language="VB" MasterPageFile="~/template/MasterPage.master"
AutoEventWireup="false" CodeFile="Default2.aspx.vb"
Inherits="template_Default2" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentHeader"
Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder"
Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentFooter"
Runat="Server">
</asp:Content>
My problem is: I want to have 3 different independent files:
header.aspx, content.aspx and footer.aspx so at the end (after creating
header and footer) I will only write content part.

Otherwise am I going to write Content1 and Content3 everytime when I
create a new page??

Thanks again,
XK

John Timney (MVP) wrote:
This is exactly what master pages are for and most of the getting started
examples you will find on the web are pretty much representitive of the type
of site you would like to put together.

Regards

John Timney (MVP)

<xk****@gmail.comwrote in message
news:11*********************@75g2000cwc.googlegrou ps.com...
Thinking of creating a website, most of the pages will have a general
toolbar
menu, a content and a footer.
The content will be the only one who's gonna change but the rest
(header,footer)
will remain the same.
I am interested to know your opinions/suggestions in finding an easy
way of doing it.
>
In asp one could have something like this:
let's say we have a page x1_page.asp
>
<!--#include file="top.asp"-->
<!--#include file="x1_content.asp"-->
<!--#include file="footer.asp"-->
>
Put it more simple for x2_page.asp I will only change the content
inclusion:
>
<!--#include file="top.asp"-->
<!--#include file="x2_content.asp"-->
<!--#include file="footer.asp"-->
>
and I don't have to change anything on top and footer.
>
>
In ASP.net 2.0 is any way to accomplish the same, or to create a
wrapper with master pages? Do you have any other ideas? PlaceHolder
maybe one even though it's
not very stright and simple.
>
Thanks,
XK
>
Jul 24 '06 #4
Probably in the future Master Pages in .net will come up with more
flexibility. In my case (still, I might be wrong) I wasn't able to get
to the point to consider them really useful.
I will probably stick with page inheritance / placeholder control.



Chris Lincoln wrote:
XK-

It is possible to have "nested" masterpages, although it is not
literally one masterpage file within another. I dont use this system
really as it seems to be pretty cumbersome.

Check out www.asp.net for tutorial videos (I found them really useful)
on masterpages in general.

Hope the videos help,

Chris

xk****@gmail.com wrote:
John, thanks for answering.
With Master Pages it's exactly what I thought at the beginning but
getting to the code part I got stuck when I had to write the content.

Let me explain, I am sure I am missing something, but I don't know
what. So if I have a master page like this:

<%@ Master Language="VB" CodeFile="MasterPage.master.vb"
Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server" <title>Untitled Page</title</head>
<body>
<form id="form1" runat="server">
<table width="100%">
<tr>
<td>
<asp:contentplaceholder id="ContentHeader" runat="server">
</asp:contentplaceholder>
</td>
</tr>
<tr>
<td>
<asp:contentplaceholder id="ContentPlaceHolder" runat="server">
</asp:contentplaceholder>
</td>
</tr>
<tr>
<td>
<asp:contentplaceholder id="ContentFooter" runat="server">
</asp:contentplaceholder>
</td>
</tr>
</table>
</form>
</body>
</html>

I end up having just ONE file for the content page:

<%@ Page Language="VB" MasterPageFile="~/template/MasterPage.master"
AutoEventWireup="false" CodeFile="Default2.aspx.vb"
Inherits="template_Default2" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentHeader"
Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder"
Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentFooter"
Runat="Server">
</asp:Content>
My problem is: I want to have 3 different independent files:
header.aspx, content.aspx and footer.aspx so at the end (after creating
header and footer) I will only write content part.

Otherwise am I going to write Content1 and Content3 everytime when I
create a new page??

Thanks again,
XK

John Timney (MVP) wrote:
This is exactly what master pages are for and most of the getting started
examples you will find on the web are pretty much representitive of the type
of site you would like to put together.
>
Regards
>
John Timney (MVP)
>
>
>
<xk****@gmail.comwrote in message
news:11*********************@75g2000cwc.googlegrou ps.com...
Thinking of creating a website, most of the pages will have a general
toolbar
menu, a content and a footer.
The content will be the only one who's gonna change but the rest
(header,footer)
will remain the same.
I am interested to know your opinions/suggestions in finding an easy
way of doing it.

In asp one could have something like this:
let's say we have a page x1_page.asp

<!--#include file="top.asp"-->
<!--#include file="x1_content.asp"-->
<!--#include file="footer.asp"-->

Put it more simple for x2_page.asp I will only change the content
inclusion:

<!--#include file="top.asp"-->
<!--#include file="x2_content.asp"-->
<!--#include file="footer.asp"-->

and I don't have to change anything on top and footer.


In ASP.net 2.0 is any way to accomplish the same, or to create a
wrapper with master pages? Do you have any other ideas? PlaceHolder
maybe one even though it's
not very stright and simple.

Thanks,
XK
Jul 25 '06 #5

xk****@gmail.com wrote:
John, thanks for answering.
With Master Pages it's exactly what I thought at the beginning but
getting to the code part I got stuck when I had to write the content.

Let me explain, I am sure I am missing something, but I don't know
what. So if I have a master page like this:

<%@ Master Language="VB" CodeFile="MasterPage.master.vb"
Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server" <title>Untitled Page</title</head>
<body>
<form id="form1" runat="server">
<table width="100%">
<tr>
<td>
<asp:contentplaceholder id="ContentHeader" runat="server">
</asp:contentplaceholder>
</td>
</tr>
<tr>
<td>
<asp:contentplaceholder id="ContentPlaceHolder" runat="server">
</asp:contentplaceholder>
</td>
</tr>
<tr>
<td>
<asp:contentplaceholder id="ContentFooter" runat="server">
</asp:contentplaceholder>
</td>
</tr>
</table>
</form>
</body>
</html>

I end up having just ONE file for the content page:

<%@ Page Language="VB" MasterPageFile="~/template/MasterPage.master"
AutoEventWireup="false" CodeFile="Default2.aspx.vb"
Inherits="template_Default2" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentHeader"
Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder"
Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentFooter"
Runat="Server">
</asp:Content>
My problem is: I want to have 3 different independent files:
header.aspx, content.aspx and footer.aspx so at the end (after creating
header and footer) I will only write content part.

Otherwise am I going to write Content1 and Content3 everytime when I
create a new page??

Thanks again,
XK
What about using UserControls (ascx) for the header and footer?

Al

Jul 25 '06 #6
You dont need content place holders for your header and footer or seprate
aspx files for these. The header and footer can be placed directly into yor
master template layout with a single (or multiple)contentplaceholder to hold
your changing content. That way, each new page at design time inherits the
master page and you only need to change the contentplaceholders contents in
each aspx. At render time, the header and footer will be appleid for you.

--
Regards

John Timney (MVP)
<xk****@gmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
John, thanks for answering.
With Master Pages it's exactly what I thought at the beginning but
getting to the code part I got stuck when I had to write the content.

Let me explain, I am sure I am missing something, but I don't know
what. So if I have a master page like this:

<%@ Master Language="VB" CodeFile="MasterPage.master.vb"
Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server" <title>Untitled Page</title</head>
<body>
<form id="form1" runat="server">
<table width="100%">
<tr>
<td>
<asp:contentplaceholder id="ContentHeader" runat="server">
</asp:contentplaceholder>
</td>
</tr>
<tr>
<td>
<asp:contentplaceholder id="ContentPlaceHolder" runat="server">
</asp:contentplaceholder>
</td>
</tr>
<tr>
<td>
<asp:contentplaceholder id="ContentFooter" runat="server">
</asp:contentplaceholder>
</td>
</tr>
</table>
</form>
</body>
</html>

I end up having just ONE file for the content page:

<%@ Page Language="VB" MasterPageFile="~/template/MasterPage.master"
AutoEventWireup="false" CodeFile="Default2.aspx.vb"
Inherits="template_Default2" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentHeader"
Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder"
Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentFooter"
Runat="Server">
</asp:Content>
My problem is: I want to have 3 different independent files:
header.aspx, content.aspx and footer.aspx so at the end (after creating
header and footer) I will only write content part.

Otherwise am I going to write Content1 and Content3 everytime when I
create a new page??

Thanks again,
XK

John Timney (MVP) wrote:
>This is exactly what master pages are for and most of the getting started
examples you will find on the web are pretty much representitive of the
type
of site you would like to put together.

Regards

John Timney (MVP)

<xk****@gmail.comwrote in message
news:11*********************@75g2000cwc.googlegro ups.com...
Thinking of creating a website, most of the pages will have a general
toolbar
menu, a content and a footer.
The content will be the only one who's gonna change but the rest
(header,footer)
will remain the same.
I am interested to know your opinions/suggestions in finding an easy
way of doing it.

In asp one could have something like this:
let's say we have a page x1_page.asp

<!--#include file="top.asp"-->
<!--#include file="x1_content.asp"-->
<!--#include file="footer.asp"-->

Put it more simple for x2_page.asp I will only change the content
inclusion:

<!--#include file="top.asp"-->
<!--#include file="x2_content.asp"-->
<!--#include file="footer.asp"-->

and I don't have to change anything on top and footer.
In ASP.net 2.0 is any way to accomplish the same, or to create a
wrapper with master pages? Do you have any other ideas? PlaceHolder
maybe one even though it's
not very stright and simple.

Thanks,
XK

Jul 25 '06 #7
In article <11**********************@m79g2000cwm.googlegroups .com>,
xk****@gmail.com writes
>Probably in the future Master Pages in .net will come up with more
flexibility. In my case (still, I might be wrong) I wasn't able to get to the
point to consider them really useful. I will probably stick with page
inheritance / placeholder control.
No, I think you need to think more about how master pages work. Your
example is perfect for them, it's your understanding of how they work
that's flawed (if you'll pardon me for saying so).

Your problem seems to be that you have defined three content place
holders in the master, one for the header, one for the content and one
for the footer. The whole purpose of the master page is that the common
parts of the page, in your case meaning the header and footer, go *in*
the master page itself. You only have a content place holder for parts
of the page that will differ, ie the content.

Create a master page like the one you showed, but replace the
ContentHeader placeholder with the actual header HTML. Similarly,
replace the ContentFooter placeholder with the actual HTML for the
footer. Then, each individual .aspx file only needs a content control
for the actual content. An example follows...

<%@ Master Language="VB" CodeFile="MasterPage.master.vb"
Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server" <title>Untitled Page</title</head>
<body>
<form id="form1" runat="server">
<table width="100%">
<tr>
<td>
<!-- header stuff goes here... -->
<h1>Fred's Ferrets Limited</h1>
<h2>The best ferrets on the web!!</h2>
</td>
</tr>
<tr>
<td>
<asp:contentplaceholder id="ContentPlaceHolder" runat="server">
</asp:contentplaceholder>
</td>
</tr>
<tr>
<td>
<!-- footer stuff goes here... -->
<p>Web site and content &copy;1923 by Fred</p>
</td>
</tr>
</table>
</form>
</body>
</html>

I hope this makes it clear. What you are doing is a classic example of
what master pages were designed for, and I would hate to see you reject
them based on a misunderstanding of how they work.

HTH

P.S. You really shouldn't be using tables to layout pages. That is a way
outdated way of doing it and bloats your pages unnecessarily. Use CSS
instead and you'll find your pages are more accessible, lighter and
significantly better seen by the search engines.

--
Alan Silver
(anything added below this line is nothing to do with me)
Aug 1 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Alan Silver | last post by:
Hello, In classic ASP, I used to use two include files on each page, one before and one after the main content, to provide a consistent layout across a web site. That way I could just change the...
2
by: Jon Spivey | last post by:
Hi, Using VS 2005/VB.net. I need to add a meta description tag and change a stylesheet link from a page based on a master page. Found this article...
3
by: samuelberthelot | last post by:
Hi, In one of my database's tables I have a Header and Footer field, which content is used to create the header and footer of my Master page. Part generated from Header field: <html > <head...
3
by: Paul | last post by:
I found a great site for CSS tempaltes, http://blog.html.it/layoutgala/ . I downloaded them, and played around with them. Then I tried to use the template in as ASP.Net MasterPage, but everything...
17
by: Rob R. Ainscough | last post by:
Again another simple concept that appears NOT to be intuitive or I'm just stupid. I've read the WROX book and the example doesn't actually show how the .master page links in the other content...
7
by: TheLongshot | last post by:
I just recently converted a few pages of my application to using master pages. Problem is, in all of my content pages, the contents are centered. I can't figure out why. The markup in the...
6
by: Steve | last post by:
Playing around with Master Pages for the first time and wanted to get thoughts on the best way to use them. Do most developers use a different Master Page for each section and then combine the...
0
by: Daniel Magliola | last post by:
I'm having a weird behaviour when implementing localization resource files in my website. This looks like a .Net bug to me, but it's too obvious to be there, so I must be overlooking something. ...
1
by: Paulo | last post by:
Hi, how can I divide a master pages in 4 parts? Header, left menu, right side (main) and footer? Just like a frame... On the header will be the a javscript menu, on left a gridview wich the user...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.