Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > master pages - header, content, footer

Reply
Thread Tools

master pages - header, content, footer

 
 
xkeops@gmail.com
Guest
Posts: n/a
 
      07-24-2006
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

 
Reply With Quote
 
 
 
 
John Timney \(MVP\)
Guest
Posts: n/a
 
      07-24-2006
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)



<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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
>



 
Reply With Quote
 
 
 
 
xkeops@gmail.com
Guest
Posts: n/a
 
      07-24-2006
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)
>
>
>
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) 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
> >


 
Reply With Quote
 
Chris Lincoln
Guest
Posts: n/a
 
      07-24-2006
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

http://www.velocityreviews.com/forums/(E-Mail Removed) 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)
> >
> >
> >
> > <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed) 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
> > >


 
Reply With Quote
 
xkeops@gmail.com
Guest
Posts: n/a
 
      07-25-2006
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
>
> (E-Mail Removed) 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)
> > >
> > >
> > >
> > > <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed) 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
> > > >


 
Reply With Quote
 
ZRat
Guest
Posts: n/a
 
      07-25-2006

(E-Mail Removed) 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

 
Reply With Quote
 
John Timney \(MVP\)
Guest
Posts: n/a
 
      07-25-2006
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)


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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)
>>
>>
>>
>> <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed) 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
>> >

>



 
Reply With Quote
 
Alan Silver
Guest
Posts: n/a
 
      08-01-2006
In article <(E-Mail Removed) .com>,
(E-Mail Removed) 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)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB Master-Details Edit (Separate Pages), Response Redirect to Master Page Databinding Issue... Sam ASP .Net 0 07-20-2006 02:31 AM
Any way to reorder how a datagrid is drawn (header/footer/items vs.header/items/footer)? Henrik ASP .Net Datagrid Control 1 07-06-2006 12:23 AM
Cross Page Post Back When Using Mixture of Master Pages and Non-Master Pages Jason@webbit.com ASP .Net 1 05-16-2006 02:00 PM
Master Pages Great! But what about Master User Controls? Electrified Research ASP .Net 5 10-11-2005 02:32 PM
seeking servlet "Master" keep getting "Master/servlet/Master" not found. Tomcat 5.0.25 Doug McCann Java 1 08-05-2004 09:16 PM



Advertisments