By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,512 Members | 3,790 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,512 IT Pros & Developers. It's quick & easy.

page templates driving me to the brink of suicide

P: n/a
I'm trying to use page inheritance so that I can derive all web pages from a
template. There are a bunch of examples at this site
http://authors.aspalliance.com/PaulW...Articles/?id=1, but strangely
enough, not a single one works with my design.

My format is quite simple: large table direcly under the <HTML> tag contains
a header usercontrol, a left side menu usercontrol and then page content.
Here is a simplified representation of my template design (you should be
able to paste this into a blank html doc):

<%@ Page language="c#" Codebehind="Template.aspx.cs" AutoEventWireup="false"
Inherits="StemCellPolitics._Template" %>
<%@ Register TagPrefix="uc1" TagName="Header" Src="_Header.ascx" %>
<%@ Register TagPrefix="uc1" TagName="Menu" Src="_Menu.ascx" %>
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<TITLE>Default</TITLE>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body>
<table id="tbl" cellSpacing="0" cols="3" cellPadding="0" width="800"
border="0">
<tr>
<td colSpan="3">
<uc1:header id="Header1" runat="server"></uc1:header></td>
</tr>
<tr>
<td vAlign="top" width="145"><uc1:menu id="Menu1"
runat="server"></uc1:menu><img height="1" src="images/1x1.gif" width="145">
</td>
<td width="20"></td>
<td valign="top">
<table cellSpacing="0" cellPadding="0" width="100%" border="0"
ID="Table1">
<TBODY>
<tr>
<td vAlign="middle" width="100%" class="PageHeading">
<!-- Page Title Goes Here-->
<hr>
<br>
</td>
</tr>
<tr>
<td>
<!-- Page Content Goes Here-->
</td>
</tr>
</table>
</td>
</tr>
</TBODY></table>
</body>
</HTML>

I have not found a technique that allows me to load the above HTML, then
load the page content, and then continue building the page HTML. Any
suggestions?

Nov 18 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
I would not recommend tables for layout, look at CCS (yes, it does loads
more than colours and fonts)

but todo this you could put your template in a server control and make it
'contain' the real webpage, I have done this with the app I am working on
now, I have a DIV in the middle and I add controls to this DIV.

Steve
"Mitch" <mi***@somew321here.com> wrote in message
news:3f**********@newspeer2.tds.net...
I'm trying to use page inheritance so that I can derive all web pages from a template. There are a bunch of examples at this site
http://authors.aspalliance.com/PaulW...Articles/?id=1, but strangely
enough, not a single one works with my design.

My format is quite simple: large table direcly under the <HTML> tag contains a header usercontrol, a left side menu usercontrol and then page content.
Here is a simplified representation of my template design (you should be
able to paste this into a blank html doc):

<%@ Page language="c#" Codebehind="Template.aspx.cs" AutoEventWireup="false" Inherits="StemCellPolitics._Template" %>
<%@ Register TagPrefix="uc1" TagName="Header" Src="_Header.ascx" %>
<%@ Register TagPrefix="uc1" TagName="Menu" Src="_Menu.ascx" %>
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<TITLE>Default</TITLE>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body>
<table id="tbl" cellSpacing="0" cols="3" cellPadding="0" width="800"
border="0">
<tr>
<td colSpan="3">
<uc1:header id="Header1" runat="server"></uc1:header></td>
</tr>
<tr>
<td vAlign="top" width="145"><uc1:menu id="Menu1"
runat="server"></uc1:menu><img height="1" src="images/1x1.gif" width="145"> </td>
<td width="20"></td>
<td valign="top">
<table cellSpacing="0" cellPadding="0" width="100%" border="0"
ID="Table1">
<TBODY>
<tr>
<td vAlign="middle" width="100%" class="PageHeading">
<!-- Page Title Goes Here-->
<hr>
<br>
</td>
</tr>
<tr>
<td>
<!-- Page Content Goes Here-->
</td>
</tr>
</table>
</td>
</tr>
</TBODY></table>
</body>
</HTML>

I have not found a technique that allows me to load the above HTML, then
load the page content, and then continue building the page HTML. Any
suggestions?

Nov 18 '05 #2

P: n/a
IMHO, I've found that using PlaceHolder controls much easier...

HTH,
Bill P.
"Mitch" <mi***@somew321here.com> wrote in message
news:3f**********@newspeer2.tds.net...
I'm trying to use page inheritance so that I can derive all web pages from a template. There are a bunch of examples at this site
http://authors.aspalliance.com/PaulW...Articles/?id=1, but strangely
enough, not a single one works with my design.

My format is quite simple: large table direcly under the <HTML> tag contains a header usercontrol, a left side menu usercontrol and then page content.
Here is a simplified representation of my template design (you should be
able to paste this into a blank html doc):

<%@ Page language="c#" Codebehind="Template.aspx.cs" AutoEventWireup="false" Inherits="StemCellPolitics._Template" %>
<%@ Register TagPrefix="uc1" TagName="Header" Src="_Header.ascx" %>
<%@ Register TagPrefix="uc1" TagName="Menu" Src="_Menu.ascx" %>
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<TITLE>Default</TITLE>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body>
<table id="tbl" cellSpacing="0" cols="3" cellPadding="0" width="800"
border="0">
<tr>
<td colSpan="3">
<uc1:header id="Header1" runat="server"></uc1:header></td>
</tr>
<tr>
<td vAlign="top" width="145"><uc1:menu id="Menu1"
runat="server"></uc1:menu><img height="1" src="images/1x1.gif" width="145"> </td>
<td width="20"></td>
<td valign="top">
<table cellSpacing="0" cellPadding="0" width="100%" border="0"
ID="Table1">
<TBODY>
<tr>
<td vAlign="middle" width="100%" class="PageHeading">
<!-- Page Title Goes Here-->
<hr>
<br>
</td>
</tr>
<tr>
<td>
<!-- Page Content Goes Here-->
</td>
</tr>
</table>
</td>
</tr>
</TBODY></table>
</body>
</HTML>

I have not found a technique that allows me to load the above HTML, then
load the page content, and then continue building the page HTML. Any
suggestions?

Nov 18 '05 #3

P: n/a
OK, I have done this and to get EVERY bit of this to work like you want, it may take some work.

I have a PageTemplate class which inherits from Page, and then my pages inherit from it.
What it does is
Creates a Form control,
Removes ALL the controls from the page's Controls collection, strips out certain values and holds them temporarily,
Creates a Table control
Loads UserControls (which are specified through properties at design time) for a banner, menu, and left column into cells of the Table,
Takes all the held Controls and adds them to the Table cell that displays the content of the page,
Adds the cells (banner, menu, left column, content) to the Table,
Adds the Table to the Form,
then RENDERS IT ALL!!! :)

'Build my new controls from scratch

'(FORM)
'
' Template Table
' |---------------------|
' | Banner |
' |---------------------|
' | Menu |
' \---------------------\ |-----|-------------|
' \ \ | Le | Content |
' \ \ | ft | |
' \ Content subtable --\----> | | (Control |
' \ \ | Col | Collection) |
' \ \ | umn | |
' \---------------------\ |-----|-------------|

I remove all the controls from the existing page, then add them to my class' form because if I just added the page's content to my table and rendered the table, the form would only contain what whas in the page, making any active content in the template pieces impossible.

Does this sound like something you're trying to do? If so, reply back to this thread.

"Mitch" <mi***@somew321here.com> wrote in message news:3f**********@newspeer2.tds.net...
I'm trying to use page inheritance so that I can derive all web pages from a
template. There are a bunch of examples at this site
http://authors.aspalliance.com/PaulW...Articles/?id=1, but strangely
enough, not a single one works with my design.

My format is quite simple: large table direcly under the <HTML> tag contains
a header usercontrol, a left side menu usercontrol and then page content.
Here is a simplified representation of my template design (you should be
able to paste this into a blank html doc):

<%@ Page language="c#" Codebehind="Template.aspx.cs" AutoEventWireup="false"
Inherits="StemCellPolitics._Template" %>
<%@ Register TagPrefix="uc1" TagName="Header" Src="_Header.ascx" %>
<%@ Register TagPrefix="uc1" TagName="Menu" Src="_Menu.ascx" %>
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<TITLE>Default</TITLE>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body>
<table id="tbl" cellSpacing="0" cols="3" cellPadding="0" width="800"
border="0">
<tr>
<td colSpan="3">
<uc1:header id="Header1" runat="server"></uc1:header></td>
</tr>
<tr>
<td vAlign="top" width="145"><uc1:menu id="Menu1"
runat="server"></uc1:menu><img height="1" src="images/1x1.gif" width="145">
</td>
<td width="20"></td>
<td valign="top">
<table cellSpacing="0" cellPadding="0" width="100%" border="0"
ID="Table1">
<TBODY>
<tr>
<td vAlign="middle" width="100%" class="PageHeading">
<!-- Page Title Goes Here-->
<hr>
<br>
</td>
</tr>
<tr>
<td>
<!-- Page Content Goes Here-->
</td>
</tr>
</table>
</td>
</tr>
</TBODY></table>
</body>
</HTML>

I have not found a technique that allows me to load the above HTML, then
load the page content, and then continue building the page HTML. Any
suggestions?


Nov 18 '05 #4

P: n/a
I'm attaching the page template I use. It allows me to design the page,
although you do need to manually delete the header, body and html tags (i.e.
you will only have the content of the page in the HTML view).

I have header and footer custom controls that emit the HTML to define the
header and footer of the page. The ones I use read in a file from disk that
contains the HTML fragments which allows me to easily modify the look of the
page without recompiling.

I will also echo the comment that CSS is a far better choice for layout than
tables. Table should be reserved for presenting tabular data, not
controlling presentation. See www.alistapart.com or http://tinyurl.com/vzf5
(link to Amazon.com).

Colin

"Mitch" <mi***@somew321here.com> wrote in message
news:3f**********@newspeer2.tds.net...
I'm trying to use page inheritance so that I can derive all web pages from a template. There are a bunch of examples at this site
http://authors.aspalliance.com/PaulW...Articles/?id=1, but strangely
enough, not a single one works with my design.

My format is quite simple: large table direcly under the <HTML> tag contains a header usercontrol, a left side menu usercontrol and then page content.
Here is a simplified representation of my template design (you should be
able to paste this into a blank html doc):

<%@ Page language="c#" Codebehind="Template.aspx.cs" AutoEventWireup="false" Inherits="StemCellPolitics._Template" %>
<%@ Register TagPrefix="uc1" TagName="Header" Src="_Header.ascx" %>
<%@ Register TagPrefix="uc1" TagName="Menu" Src="_Menu.ascx" %>
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<TITLE>Default</TITLE>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body>
<table id="tbl" cellSpacing="0" cols="3" cellPadding="0" width="800"
border="0">
<tr>
<td colSpan="3">
<uc1:header id="Header1" runat="server"></uc1:header></td>
</tr>
<tr>
<td vAlign="top" width="145"><uc1:menu id="Menu1"
runat="server"></uc1:menu><img height="1" src="images/1x1.gif" width="145"> </td>
<td width="20"></td>
<td valign="top">
<table cellSpacing="0" cellPadding="0" width="100%" border="0"
ID="Table1">
<TBODY>
<tr>
<td vAlign="middle" width="100%" class="PageHeading">
<!-- Page Title Goes Here-->
<hr>
<br>
</td>
</tr>
<tr>
<td>
<!-- Page Content Goes Here-->
</td>
</tr>
</table>
</td>
</tr>
</TBODY></table>
</body>
</HTML>

I have not found a technique that allows me to load the above HTML, then
load the page content, and then continue building the page HTML. Any
suggestions?

Nov 18 '05 #5

P: n/a
Here is a link to an article that talks about a different approach to
creating page templates:
http://www.smartisans.com/articles/vb_templates.aspx

This approach is similar to the Master Pages concept MS is creating in
ASP.NETv2.

Jeff
"Colin Young" <x@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I'm attaching the page template I use. It allows me to design the page,
although you do need to manually delete the header, body and html tags (i.e. you will only have the content of the page in the HTML view).

I have header and footer custom controls that emit the HTML to define the
header and footer of the page. The ones I use read in a file from disk that contains the HTML fragments which allows me to easily modify the look of the page without recompiling.

I will also echo the comment that CSS is a far better choice for layout than tables. Table should be reserved for presenting tabular data, not
controlling presentation. See www.alistapart.com or http://tinyurl.com/vzf5 (link to Amazon.com).

Colin

"Mitch" <mi***@somew321here.com> wrote in message
news:3f**********@newspeer2.tds.net...
I'm trying to use page inheritance so that I can derive all web pages from
a
template. There are a bunch of examples at this site
http://authors.aspalliance.com/PaulW...Articles/?id=1, but strangely
enough, not a single one works with my design.

My format is quite simple: large table direcly under the <HTML> tag

contains
a header usercontrol, a left side menu usercontrol and then page

content. Here is a simplified representation of my template design (you should be
able to paste this into a blank html doc):

<%@ Page language="c#" Codebehind="Template.aspx.cs"

AutoEventWireup="false"
Inherits="StemCellPolitics._Template" %>
<%@ Register TagPrefix="uc1" TagName="Header" Src="_Header.ascx" %>
<%@ Register TagPrefix="uc1" TagName="Menu" Src="_Menu.ascx" %>
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<TITLE>Default</TITLE>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body>
<table id="tbl" cellSpacing="0" cols="3" cellPadding="0" width="800"
border="0">
<tr>
<td colSpan="3">
<uc1:header id="Header1" runat="server"></uc1:header></td>
</tr>
<tr>
<td vAlign="top" width="145"><uc1:menu id="Menu1"
runat="server"></uc1:menu><img height="1" src="images/1x1.gif"

width="145">
</td>
<td width="20"></td>
<td valign="top">
<table cellSpacing="0" cellPadding="0" width="100%" border="0"
ID="Table1">
<TBODY>
<tr>
<td vAlign="middle" width="100%" class="PageHeading">
<!-- Page Title Goes Here-->
<hr>
<br>
</td>
</tr>
<tr>
<td>
<!-- Page Content Goes Here-->
</td>
</tr>
</table>
</td>
</tr>
</TBODY></table>
</body>
</HTML>

I have not found a technique that allows me to load the above HTML, then
load the page content, and then continue building the page HTML. Any
suggestions?


Nov 18 '05 #6

P: n/a
I guess they took a look at the proliferation of articles on creating page
templates and decided they had better do something about it.

That article has a good set of links at the end to other articles on page
templates. I used information from almost all of them to come up with my
solution.

Colin

"Jeff" <js****@nospam.dls.net> wrote in message
news:OI**************@TK2MSFTNGP11.phx.gbl...
Here is a link to an article that talks about a different approach to
creating page templates:
http://www.smartisans.com/articles/vb_templates.aspx

This approach is similar to the Master Pages concept MS is creating in
ASP.NETv2.

Jeff
"Colin Young" <x@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I'm attaching the page template I use. It allows me to design the page,
although you do need to manually delete the header, body and html tags

(i.e.
you will only have the content of the page in the HTML view).

I have header and footer custom controls that emit the HTML to define the
header and footer of the page. The ones I use read in a file from disk

that
contains the HTML fragments which allows me to easily modify the look of

the
page without recompiling.

I will also echo the comment that CSS is a far better choice for layout

than
tables. Table should be reserved for presenting tabular data, not
controlling presentation. See www.alistapart.com or

http://tinyurl.com/vzf5
(link to Amazon.com).

Colin

"Mitch" <mi***@somew321here.com> wrote in message
news:3f**********@newspeer2.tds.net...
I'm trying to use page inheritance so that I can derive all web pages

from
a
template. There are a bunch of examples at this site
http://authors.aspalliance.com/PaulW...Articles/?id=1, but strangely enough, not a single one works with my design.

My format is quite simple: large table direcly under the <HTML> tag

contains
a header usercontrol, a left side menu usercontrol and then page

content. Here is a simplified representation of my template design (you should be able to paste this into a blank html doc):

<%@ Page language="c#" Codebehind="Template.aspx.cs"

AutoEventWireup="false"
Inherits="StemCellPolitics._Template" %>
<%@ Register TagPrefix="uc1" TagName="Header" Src="_Header.ascx" %>
<%@ Register TagPrefix="uc1" TagName="Menu" Src="_Menu.ascx" %>
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<TITLE>Default</TITLE>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body>
<table id="tbl" cellSpacing="0" cols="3" cellPadding="0" width="800"
border="0">
<tr>
<td colSpan="3">
<uc1:header id="Header1" runat="server"></uc1:header></td>
</tr>
<tr>
<td vAlign="top" width="145"><uc1:menu id="Menu1"
runat="server"></uc1:menu><img height="1" src="images/1x1.gif"

width="145">
</td>
<td width="20"></td>
<td valign="top">
<table cellSpacing="0" cellPadding="0" width="100%" border="0"
ID="Table1">
<TBODY>
<tr>
<td vAlign="middle" width="100%" class="PageHeading">
<!-- Page Title Goes Here-->
<hr>
<br>
</td>
</tr>
<tr>
<td>
<!-- Page Content Goes Here-->
</td>
</tr>
</table>
</td>
</tr>
</TBODY></table>
</body>
</HTML>

I have not found a technique that allows me to load the above HTML, then load the page content, and then continue building the page HTML. Any
suggestions?



Nov 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.