.NETGURU
Page Templating
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngreuse' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Little, Ambrose
Has anyone implemented page templating using the method described in
http://www.fawcette.com/vsm/2001_12/magazine/columns/aspnet/default.asp
(inheriting your code-behind page class from a custom page class using
placeholders, etc.)?

What are the pros/cons of this approach as regards speed (and
maintainability)?

It's sounds cool, except it seems that for every page you'd have to have an
ASPX that inherits from the custom template and sets up the various reusable
stuff, and then you'd have to have an ASCX for every ASPX containing the
body stuff particular to that page. Seems a little redundant, and I'm not
sure what it has to offer over just putting the controls on each ASPX page
and using includes for the basic HTML structure.

In addition, it seems like it may add some overhead in loading extra
controls for the page. So any thoughts are appreciated.

--Ambrose

******************************************************************************
The Company reserves the right to amend statements
made herein in the event of a mistake. Unless expressly
stated herein to the contrary, only agreements in writing signed
by an authorized officer of the Company may be enforced against it.
*******************************************************************************

Reply to this message...
 
    
Ryan Trudelle-Schwarz
As a friend of mine would say, "Caching hides all sins". While I don't =
agree with this completely, it does apply in this circumstance.

As for the technique used in this article... It's ugly to the user of =
the template, something that should be avoided if at all possible. =
That's why I created a templating scheme of my own. =
(http://www.aspalliance.com/mamanze/articles/default.aspx?path=3Dpagetemp=
late)

Many people have been implementing it lately and so far I've only heard =
good things about it.

Hth, Ryan

-----Original Message-----
From: Little, Ambrose [mailto:Click here to reveal e-mail address]=20
=20
Has anyone implemented page templating using the method described in
http://www.fawcette.com/vsm/2001_12/magazine/columns/aspnet/default.asp
(inheriting your code-behind page class from a custom page class using
placeholders, etc.)?

What are the pros/cons of this approach as regards speed (and
maintainability)?

It's sounds cool, except it seems that for every page you'd have to have =
an
ASPX that inherits from the custom template and sets up the various =
reusable
stuff, and then you'd have to have an ASCX for every ASPX containing the
body stuff particular to that page. Seems a little redundant, and I'm =
not
sure what it has to offer over just putting the controls on each ASPX =
page
and using includes for the basic HTML structure.

In addition, it seems like it may add some overhead in loading extra
controls for the page. So any thoughts are appreciated.

--Ambrose

---
[This E-mail scanned for viruses by Declude Virus]

Reply to this message...
 
    
Steven A Smith (VIP)
Hey now, that's "Caching hides many sins."

Some things, even caching can't hide...

:)

Steve, Ryan's friend.

----- Original Message -----
From: "Ryan Trudelle-Schwarz" <Click here to reveal e-mail address>
To: "aspngreuse" <Click here to reveal e-mail address>
Sent: Wednesday, May 15, 2002 1:35 PM
Subject: [aspngreuse] RE: Page Templating

As a friend of mine would say, "Caching hides all sins". While I don't agree
with this completely, it does apply in this circumstance.

As for the technique used in this article... It's ugly to the user of the
template, something that should be avoided if at all possible. That's why I
created a templating scheme of my own.
(http://www.aspalliance.com/mamanze/articles/default.aspx?path=pagetemplate)

Many people have been implementing it lately and so far I've only heard good
things about it.

Hth, Ryan

-----Original Message-----
From: Little, Ambrose [mailto:Click here to reveal e-mail address]

Has anyone implemented page templating using the method described in
http://www.fawcette.com/vsm/2001_12/magazine/columns/aspnet/default.asp
(inheriting your code-behind page class from a custom page class using
placeholders, etc.)?

What are the pros/cons of this approach as regards speed (and
maintainability)?

It's sounds cool, except it seems that for every page you'd have to have an
ASPX that inherits from the custom template and sets up the various reusable
stuff, and then you'd have to have an ASCX for every ASPX containing the
body stuff particular to that page. Seems a little redundant, and I'm not
sure what it has to offer over just putting the controls on each ASPX page
and using includes for the basic HTML structure.

In addition, it seems like it may add some overhead in loading extra
controls for the page. So any thoughts are appreciated.

--Ambrose

---
[This E-mail scanned for viruses by Declude Virus]

| [aspngreuse] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngreuse.asp = JOIN/QUIT

Reply to this message...
 
    
Little, Ambrose
Okay, I'm not quite sure I totally get this. The part I'm unclear on is how
to use the template. The example you provide just has some simple div's in
the aspx, but what if I needed a full-fledged form with a bunch of controls
in it? How would the template handle that? Would I be able to write it
like a normal web form or what (where would events be handled)? Also, let's
say the nav needs to be customized on a particular page. Would I have
access to a control that's loaded in the template? If so, how?

If you have examples of these sorts of things, I'd appreciate seeing them.

--Ambrose

[Original message clipped]


Many people have been implementing it lately and so far I've only heard good
things about it.

Hth, Ryan

-----Original Message-----
From: Little, Ambrose [mailto:Click here to reveal e-mail address]

Has anyone implemented page templating using the method described in
http://www.fawcette.com/vsm/2001_12/magazine/columns/aspnet/default.asp
(inheriting your code-behind page class from a custom page class using
placeholders, etc.)?

What are the pros/cons of this approach as regards speed (and
maintainability)?

It's sounds cool, except it seems that for every page you'd have to have an
ASPX that inherits from the custom template and sets up the various reusable
stuff, and then you'd have to have an ASCX for every ASPX containing the
body stuff particular to that page. Seems a little redundant, and I'm not
sure what it has to offer over just putting the controls on each ASPX page
and using includes for the basic HTML structure.

In addition, it seems like it may add some overhead in loading extra
controls for the page. So any thoughts are appreciated.

--Ambrose

---
[This E-mail scanned for viruses by Declude Virus]

| [aspngreuse] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngreuse.asp = JOIN/QUIT

******************************************************************************
The Company reserves the right to amend statements
made herein in the event of a mistake. Unless expressly
stated herein to the contrary, only agreements in writing signed
by an authorized officer of the Company may be enforced against it.
*******************************************************************************

Reply to this message...
 
    
Ollie Cornes

This is superb Ryan! I remember you explained it to me a while back and I
couldn't figure it out, but having seen some code I have to say this is
something special. Here's some thoughts...

- I found VS.NET was breaking the template page. It sometimes removed the
tag close / from the link tag.
- I changed the div tag into a PlaceHolder as in my site I don't need a
wrapping div. That meant changing the type of the Content property in
IPageTemplate, I used Control. That worked fine.
- I'd suggest adding support for the "~" operator in the Title and
Stylesheet entries in the web.config. Just check for "~/" and replace it
with Request.ApplicationPath.
- If you have the time, it'd be great for people downloading the code to see
a simple working example, I noticed some of your code links to some user
controls that don't exist (I guess they're in your site, but not included in
the archive).

The thing I love about your solution is that the template can be edited as a
page. My previous solution has been to use a pair of user controls, one for
the start of the page and one for the end, but your solution is much better
as the template is held in once, editable file.

Well done! I think it's well worth posting this to aspngcommunity and
aspngarchitecture if you haven't already.

Ollie
--
http://www.RichTextBox.com
The easy way to add formatted text editing to your ASP.NET web site

----- Original Message -----
From: "Ryan Trudelle-Schwarz" <Click here to reveal e-mail address>
To: "aspngreuse" <Click here to reveal e-mail address>
Sent: Wednesday, May 15, 2002 6:35 PM
Subject: [aspngreuse] RE: Page Templating

As a friend of mine would say, "Caching hides all sins". While I don't agree
with this completely, it does apply in this circumstance.

As for the technique used in this article... It's ugly to the user of the
template, something that should be avoided if at all possible. That's why I
created a templating scheme of my own.
(http://www.aspalliance.com/mamanze/articles/default.aspx?path=pagetemplate)

Many people have been implementing it lately and so far I've only heard good
things about it.

Hth, Ryan

-----Original Message-----
From: Little, Ambrose [mailto:Click here to reveal e-mail address]

Has anyone implemented page templating using the method described in
http://www.fawcette.com/vsm/2001_12/magazine/columns/aspnet/default.asp
(inheriting your code-behind page class from a custom page class using
placeholders, etc.)?

What are the pros/cons of this approach as regards speed (and
maintainability)?

It's sounds cool, except it seems that for every page you'd have to have an
ASPX that inherits from the custom template and sets up the various reusable
stuff, and then you'd have to have an ASCX for every ASPX containing the
body stuff particular to that page. Seems a little redundant, and I'm not
sure what it has to offer over just putting the controls on each ASPX page
and using includes for the basic HTML structure.

In addition, it seems like it may add some overhead in loading extra
controls for the page. So any thoughts are appreciated.

--Ambrose

---
[This E-mail scanned for viruses by Declude Virus]

| [aspngreuse] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngreuse.asp = JOIN/QUIT

Reply to this message...
 
    
Daniel Naumann
All,

I've checked out Ryan's template method before and I think it si by far =
the best solution I've seen - simple and effective. It's an approach I =
haven't seen before.

There is an example you can download from the site. I had to made =
several changes, but got it working without to much grief. I then =
played around with adding other control etc. and it all worked =
beautifully (to answer Ambrose's question).

I plan to use it in my next project. Thanks Ryan.

Daniel.

-----Original Message-----
From: Ryan Trudelle-Schwarz [mailto:Click here to reveal e-mail address]
Sent: 16-May-2002 03:36
To: aspngreuse
Subject: [aspngreuse] RE: Page Templating

As a friend of mine would say, "Caching hides all sins". While I don't =
agree with this completely, it does apply in this circumstance.

As for the technique used in this article... It's ugly to the user of =
the template, something that should be avoided if at all possible. =
That's why I created a templating scheme of my own. =
(http://www.aspalliance.com/mamanze/articles/default.aspx?path=3Dpagetemp=
late)

Many people have been implementing it lately and so far I've only heard =
good things about it.

Hth, Ryan

-----Original Message-----
From: Little, Ambrose [mailto:Click here to reveal e-mail address]=20
=20
Has anyone implemented page templating using the method described in
http://www.fawcette.com/vsm/2001_12/magazine/columns/aspnet/default.asp
(inheriting your code-behind page class from a custom page class using
placeholders, etc.)?

What are the pros/cons of this approach as regards speed (and
maintainability)?

It's sounds cool, except it seems that for every page you'd have to have =
an
ASPX that inherits from the custom template and sets up the various =
reusable
stuff, and then you'd have to have an ASCX for every ASPX containing the
body stuff particular to that page. Seems a little redundant, and I'm =
not
sure what it has to offer over just putting the controls on each ASPX =
page
and using includes for the basic HTML structure.

In addition, it seems like it may add some overhead in loading extra
controls for the page. So any thoughts are appreciated.

--Ambrose

---
[This E-mail scanned for viruses by Declude Virus]

| [aspngreuse] member Click here to reveal e-mail address =3D YOUR ID
| http://www.aspfriends.com/aspfriends/aspngreuse.asp =3D JOIN/QUIT

Reply to this message...
 
    
Ollie Cornes

If you want to add support for "~/", you can pass the template/stylesheet
path through this method:

private string ProcessWebPath(string path)
{
if (path.StartsWith("~/"))
{
return HttpContext.Current.Request.ApplicationPath + "/" +
path.Substring(2);
}
else
{
return path;
}
}

I was thinking about how it could be extended for multiple templates in a
site. Then, for any given page, it's possible to do something like this in
the Page_Load:

this.Template = "RedBackground"; // choose the template for this page
this.Title = "My demonstration page"; // override default title

In the web.config you could then have:

<add key="RedBackground_Template" value="~/TemplateR.ascx"/>
<add key="RedBackground_Stylesheet" value="~/stylesR.css" />
<add key="RedBackground_DefaultTitle" value="My Red Page" />
<add key="BlueBackground_Template" value="~/TemplateB.ascx"/>
<add key="BlueBackground_Stylesheet" value="~/stylesB.css" />
<add key="BlueBackground_DefaultTitle" value="My Blue Page" />

(maybe use a hierarchical structure for this?)

And as an added bonus, as the template uses codebehind, it can do its own
checks. For example a template could decide only show a certain UI object
(advert, navigation, etc) in specific areas of the site. e.g. an e-commerce
site wouldn't want to show a "Buy Now!" banner during the shopping process.

Ryan, I'll lend a hand with this if you like. I'd love to see this developed
as it's a MUCH better way to handle the templating problems most of us face
when we build sites.

What do you think?

Ollie
--
http://www.RichTextBox.com
The easy way to add formatted text editing to your ASP.NET web site

----- Original Message -----
From: "Ryan Trudelle-Schwarz" <Click here to reveal e-mail address>
To: "aspngreuse" <Click here to reveal e-mail address>
Sent: Wednesday, May 15, 2002 6:35 PM
Subject: [aspngreuse] RE: Page Templating

As a friend of mine would say, "Caching hides all sins". While I don't agree
with this completely, it does apply in this circumstance.

As for the technique used in this article... It's ugly to the user of the
template, something that should be avoided if at all possible. That's why I
created a templating scheme of my own.
(http://www.aspalliance.com/mamanze/articles/default.aspx?path=pagetemplate)

Many people have been implementing it lately and so far I've only heard good
things about it.

Hth, Ryan

-----Original Message-----
From: Little, Ambrose [mailto:Click here to reveal e-mail address]

Has anyone implemented page templating using the method described in
http://www.fawcette.com/vsm/2001_12/magazine/columns/aspnet/default.asp
(inheriting your code-behind page class from a custom page class using
placeholders, etc.)?

What are the pros/cons of this approach as regards speed (and
maintainability)?

It's sounds cool, except it seems that for every page you'd have to have an
ASPX that inherits from the custom template and sets up the various reusable
stuff, and then you'd have to have an ASCX for every ASPX containing the
body stuff particular to that page. Seems a little redundant, and I'm not
sure what it has to offer over just putting the controls on each ASPX page
and using includes for the basic HTML structure.

In addition, it seems like it may add some overhead in loading extra
controls for the page. So any thoughts are appreciated.

--Ambrose

---
[This E-mail scanned for viruses by Declude Virus]

| [aspngreuse] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngreuse.asp = JOIN/QUIT

Reply to this message...
 
    
Ryan Trudelle-Schwarz
Sounds good. Personally I don't think I'll ever use the ~ notation but =
others might.=20

Along with this, does anyone have any fully working samples of this =
technique for page templating? Would be nice if we could post those for =
others to see.

Thanks, Ryan

-----Original Message-----
From: Ollie Cornes [mailto:Click here to reveal e-mail address]=20

If you want to add support for "~/", you can pass the =
template/stylesheet
path through this method:

private string ProcessWebPath(string path)
{
if (path.StartsWith("~/"))
{
return HttpContext.Current.Request.ApplicationPath + "/" +
path.Substring(2);
}
else
{
return path;
}
}

I was thinking about how it could be extended for multiple templates in =
a
site. Then, for any given page, it's possible to do something like this =
in
the Page_Load:

this.Template =3D "RedBackground"; // choose the template for this page
this.Title =3D "My demonstration page"; // override default title

In the web.config you could then have:

<add key=3D"RedBackground_Template" value=3D"~/TemplateR.ascx"/>
<add key=3D"RedBackground_Stylesheet" value=3D"~/stylesR.css" />
<add key=3D"RedBackground_DefaultTitle" value=3D"My Red Page" />
<add key=3D"BlueBackground_Template" value=3D"~/TemplateB.ascx"/>
<add key=3D"BlueBackground_Stylesheet" value=3D"~/stylesB.css" />
<add key=3D"BlueBackground_DefaultTitle" value=3D"My Blue Page" />

(maybe use a hierarchical structure for this?)

And as an added bonus, as the template uses codebehind, it can do its =
own
checks. For example a template could decide only show a certain UI =
object
(advert, navigation, etc) in specific areas of the site. e.g. an =
e-commerce
site wouldn't want to show a "Buy Now!" banner during the shopping =
process.

Ryan, I'll lend a hand with this if you like. I'd love to see this =
developed
as it's a MUCH better way to handle the templating problems most of us =
face
when we build sites.

What do you think?

Ollie
--
http://www.RichTextBox.com
The easy way to add formatted text editing to your ASP.NET web site

----- Original Message -----
From: "Ryan Trudelle-Schwarz" <Click here to reveal e-mail address>

As a friend of mine would say, "Caching hides all sins". While I don't =
agree
with this completely, it does apply in this circumstance.

As for the technique used in this article... It's ugly to the user of =
the
template, something that should be avoided if at all possible. That's =
why I
created a templating scheme of my own.
(http://www.aspalliance.com/mamanze/articles/default.aspx?path=3Dpagetemp=
late)

Many people have been implementing it lately and so far I've only heard =
good
things about it.

Hth, Ryan

-----Original Message-----
From: Little, Ambrose [mailto:Click here to reveal e-mail address]

Has anyone implemented page templating using the method described in
http://www.fawcette.com/vsm/2001_12/magazine/columns/aspnet/default.asp
(inheriting your code-behind page class from a custom page class using
placeholders, etc.)?

What are the pros/cons of this approach as regards speed (and
maintainability)?

It's sounds cool, except it seems that for every page you'd have to have =
an
ASPX that inherits from the custom template and sets up the various =
reusable
stuff, and then you'd have to have an ASCX for every ASPX containing the
body stuff particular to that page. Seems a little redundant, and I'm =
not
sure what it has to offer over just putting the controls on each ASPX =
page
and using includes for the basic HTML structure.

In addition, it seems like it may add some overhead in loading extra
controls for the page. So any thoughts are appreciated.

--Ambrose

---
[This E-mail scanned for viruses by Declude Virus]

Reply to this message...
 
    
Scott Watermasysk (VIP)
I think this differs slightly from what Ollie and Ryan have been talking
about, but I figured I chime in and share what I have done from
TripleASP.Net

I still have to clean it up a bit, but here is what I have been doing for
page templates.

I created my own base class from Page. Added a couple of overrideable
methods with a default layout.
You can view the code here:
http://tripleasp.net/showcode/template/templates.cs.code

Next, I created an ASPX page with my sites general layout that I could
include in any page that needed it (this html/aspx is very IBS like):
http://tripleasp.net/showcode/template/html.aspx.code . Some of the style
features are still a little too "hard coded", but for my needs this was OK.

From here, to add a new page to the site, I simply include the html.aspx
page and inhert from my template class:
http://tripleasp.net/showcode/template/article.aspx.code and
http://tripleasp.net/showcode/template/article.aspx.cs.code

Or, as you might have seen in the templates.cs.code link, I created a couple
of default pages that inhert directly from my template class. So inorder to
build my about page, (http://TripleASP.Net/About.aspx) all I had to do is
inherit from my simplecontent class:
http://tripleasp.net/showcode/template/about.aspx.cs.code

If anyone is interested, I can put some kind of download and/or article
together on this.

-Scott

-----Original Message-----
From: Ryan Trudelle-Schwarz [mailto:Click here to reveal e-mail address]
Sent: Thursday, May 16, 2002 10:23 AM
To: aspngreuse
Subject: [aspngreuse] RE: Page Templating

Sounds good. Personally I don't think I'll ever use the ~ notation but
others might.

Along with this, does anyone have any fully working samples of this
technique for page templating? Would be nice if we could post those for
others to see.

Thanks, Ryan

-----Original Message-----
From: Ollie Cornes [mailto:Click here to reveal e-mail address]

If you want to add support for "~/", you can pass the template/stylesheet
path through this method:

private string ProcessWebPath(string path)
{
if (path.StartsWith("~/"))
{
return HttpContext.Current.Request.ApplicationPath + "/" +
path.Substring(2); } else {
return path;
}
}

I was thinking about how it could be extended for multiple templates in a
site. Then, for any given page, it's possible to do something like this in
the Page_Load:

this.Template = "RedBackground"; // choose the template for this page
this.Title = "My demonstration page"; // override default title

In the web.config you could then have:

<add key="RedBackground_Template" value="~/TemplateR.ascx"/> <add
key="RedBackground_Stylesheet" value="~/stylesR.css" /> <add
key="RedBackground_DefaultTitle" value="My Red Page" /> <add
key="BlueBackground_Template" value="~/TemplateB.ascx"/> <add
key="BlueBackground_Stylesheet" value="~/stylesB.css" /> <add
key="BlueBackground_DefaultTitle" value="My Blue Page" />

(maybe use a hierarchical structure for this?)

And as an added bonus, as the template uses codebehind, it can do its own
checks. For example a template could decide only show a certain UI object
(advert, navigation, etc) in specific areas of the site. e.g. an e-commerce
site wouldn't want to show a "Buy Now!" banner during the shopping process.

Ryan, I'll lend a hand with this if you like. I'd love to see this developed
as it's a MUCH better way to handle the templating problems most of us face
when we build sites.

What do you think?

Ollie
--
http://www.RichTextBox.com
The easy way to add formatted text editing to your ASP.NET web site

----- Original Message -----
From: "Ryan Trudelle-Schwarz" <Click here to reveal e-mail address>

As a friend of mine would say, "Caching hides all sins". While I don't agree
with this completely, it does apply in this circumstance.

As for the technique used in this article... It's ugly to the user of the
template, something that should be avoided if at all possible. That's why I
created a templating scheme of my own.
(http://www.aspalliance.com/mamanze/articles/default.aspx?path=pagetemplate)

Many people have been implementing it lately and so far I've only heard good
things about it.

Hth, Ryan

-----Original Message-----
From: Little, Ambrose [mailto:Click here to reveal e-mail address]

Has anyone implemented page templating using the method described in
http://www.fawcette.com/vsm/2001_12/magazine/columns/aspnet/default.asp
(inheriting your code-behind page class from a custom page class using
placeholders, etc.)?

What are the pros/cons of this approach as regards speed (and
maintainability)?

It's sounds cool, except it seems that for every page you'd have to have an
ASPX that inherits from the custom template and sets up the various reusable
stuff, and then you'd have to have an ASCX for every ASPX containing the
body stuff particular to that page. Seems a little redundant, and I'm not
sure what it has to offer over just putting the controls on each ASPX page
and using includes for the basic HTML structure.

In addition, it seems like it may add some overhead in loading extra
controls for the page. So any thoughts are appreciated.

--Ambrose

---
[This E-mail scanned for viruses by Declude Virus]

| [aspngreuse] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngreuse.asp = JOIN/QUIT

Reply to this message...
 
    
RBFigueira@montepiogeral.pt
Scott,

We love to see it.

Please, put some small working sample, to test, with some comments :P

Thanks for sharing :P

Best regards,
Ricardo Figueira (RBFIGUEIRA)

-----Original Message-----
From: Scott Watermasysk [mailto:Click here to reveal e-mail address]
Sent: quinta-feira, 16 de Maio de 2002 16:22
To: aspngreuse
Subject: [aspngreuse] RE: Page Templating

I think this differs slightly from what Ollie and Ryan have been talking
about, but I figured I chime in and share what I have done from
TripleASP.Net

I still have to clean it up a bit, but here is what I have been doing for
page templates.

I created my own base class from Page. Added a couple of overrideable
methods with a default layout.
You can view the code here:
http://tripleasp.net/showcode/template/templates.cs.code

Next, I created an ASPX page with my sites general layout that I could
include in any page that needed it (this html/aspx is very IBS like):
http://tripleasp.net/showcode/template/html.aspx.code . Some of the style
features are still a little too "hard coded", but for my needs this was OK.

From here, to add a new page to the site, I simply include the html.aspx
page and inhert from my template class:
http://tripleasp.net/showcode/template/article.aspx.code and
http://tripleasp.net/showcode/template/article.aspx.cs.code

Or, as you might have seen in the templates.cs.code link, I created a couple
of default pages that inhert directly from my template class. So inorder to
build my about page, (http://TripleASP.Net/About.aspx) all I had to do is
inherit from my simplecontent class:
http://tripleasp.net/showcode/template/about.aspx.cs.code

If anyone is interested, I can put some kind of download and/or article
together on this.

-Scott

-----Original Message-----
From: Ryan Trudelle-Schwarz [mailto:Click here to reveal e-mail address]
Sent: Thursday, May 16, 2002 10:23 AM
To: aspngreuse
Subject: [aspngreuse] RE: Page Templating

Sounds good. Personally I don't think I'll ever use the ~ notation but
others might.

Along with this, does anyone have any fully working samples of this
technique for page templating? Would be nice if we could post those for
others to see.

Thanks, Ryan

-----Original Message-----
From: Ollie Cornes [mailto:Click here to reveal e-mail address]

If you want to add support for "~/", you can pass the template/stylesheet
path through this method:

private string ProcessWebPath(string path)
{
if (path.StartsWith("~/"))
{
return HttpContext.Current.Request.ApplicationPath + "/" +
path.Substring(2); } else {
return path;
}
}

I was thinking about how it could be extended for multiple templates in a
site. Then, for any given page, it's possible to do something like this in
the Page_Load:

this.Template = "RedBackground"; // choose the template for this page
this.Title = "My demonstration page"; // override default title

In the web.config you could then have:

<add key="RedBackground_Template" value="~/TemplateR.ascx"/> <add
key="RedBackground_Stylesheet" value="~/stylesR.css" /> <add
key="RedBackground_DefaultTitle" value="My Red Page" /> <add
key="BlueBackground_Template" value="~/TemplateB.ascx"/> <add
key="BlueBackground_Stylesheet" value="~/stylesB.css" /> <add
key="BlueBackground_DefaultTitle" value="My Blue Page" />

(maybe use a hierarchical structure for this?)

And as an added bonus, as the template uses codebehind, it can do its own
checks. For example a template could decide only show a certain UI object
(advert, navigation, etc) in specific areas of the site. e.g. an e-commerce
site wouldn't want to show a "Buy Now!" banner during the shopping process.

Ryan, I'll lend a hand with this if you like. I'd love to see this developed
as it's a MUCH better way to handle the templating problems most of us face
when we build sites.

What do you think?

Ollie
--
http://www.RichTextBox.com
The easy way to add formatted text editing to your ASP.NET web site

----- Original Message -----
From: "Ryan Trudelle-Schwarz" <Click here to reveal e-mail address>

As a friend of mine would say, "Caching hides all sins". While I don't agree
with this completely, it does apply in this circumstance.

As for the technique used in this article... It's ugly to the user of the
template, something that should be avoided if at all possible. That's why I
created a templating scheme of my own.
(http://www.aspalliance.com/mamanze/articles/default.aspx?path=pagetemplate)

Many people have been implementing it lately and so far I've only heard good
things about it.

Hth, Ryan

-----Original Message-----
From: Little, Ambrose [mailto:Click here to reveal e-mail address]

Has anyone implemented page templating using the method described in
http://www.fawcette.com/vsm/2001_12/magazine/columns/aspnet/default.asp
(inheriting your code-behind page class from a custom page class using
placeholders, etc.)?

What are the pros/cons of this approach as regards speed (and
maintainability)?

It's sounds cool, except it seems that for every page you'd have to have an
ASPX that inherits from the custom template and sets up the various reusable
stuff, and then you'd have to have an ASCX for every ASPX containing the
body stuff particular to that page. Seems a little redundant, and I'm not
sure what it has to offer over just putting the controls on each ASPX page
and using includes for the basic HTML structure.

In addition, it seems like it may add some overhead in loading extra
controls for the page. So any thoughts are appreciated.

--Ambrose

---
[This E-mail scanned for viruses by Declude Virus]

| [aspngreuse] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngreuse.asp = JOIN/QUIT

| [aspngreuse] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngreuse.asp = JOIN/QUIT

Reply to this message...
 
    
Brian W. Spolarich

| If anyone is interested, I can put some kind of download=20
| and/or article together on this.

I'd like to see this code. What's the functionality behind the =
caching code (TANconfig), and is it something you're willing to share?=20

-bws

Reply to this message...
 
    
RBFigueira@montepiogeral.pt
Friend,

I was analazing this code and to understand and to put this code to work we
need to know some parts like :

using TripleASP.Cache
using TripleASP.Configuration

What is behind this, can you share this classes?
Can you do an working sample ?

Thanks :P

Best regards,
Ricardo Figueira

-----Original Message-----
From: Brian W. Spolarich [mailto:Click here to reveal e-mail address]
Sent: quinta-feira, 16 de Maio de 2002 20:15
To: aspngreuse
Subject: [aspngreuse] RE: Page Templating

| If anyone is interested, I can put some kind of download
| and/or article together on this.

I'd like to see this code. What's the functionality behind the caching
code (TANconfig), and is it something you're willing to share?

-bws

| [aspngreuse] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngreuse.asp = JOIN/QUIT

Reply to this message...
 
    
Tim Royal
This looks really good. I can follow it (the other examples, I'm afraid, are
far beyond me at this point, though I'm sure they're valuable additions).

So these controls that you load, did you break up your site into discrete
pieces and then build .ascx pages for each component (hence the dynamic
loading)?

Have you run into gotchas in doing so. One of my fears is that I build this
great architecture for a site, but then the management wants to 'shoehorn'
in some feature that sends my beautiful creation into chaos. Perhaps that's
not as problematic as I fear using this.

Tim

->-----Original Message-----
->From: Click here to reveal e-mail address [mailto:Click here to reveal e-mail address]
->Sent: Thursday, May 16, 2002 8:48 AM
->To: aspngreuse
->Cc: Click here to reveal e-mail address
->Subject: [aspngreuse] RE: Page Templating
->
->
->Scott,
->
->We love to see it.
->
->Please, put some small working sample, to test, with some comments :P
->
->Thanks for sharing :P
->
->Best regards,
->Ricardo Figueira (RBFIGUEIRA)
->
->-----Original Message-----
->From: Scott Watermasysk
->[mailto:Click here to reveal e-mail address]
->Sent: quinta-feira, 16 de Maio de 2002 16:22
->To: aspngreuse
->Subject: [aspngreuse] RE: Page Templating
->
->
->I think this differs slightly from what Ollie and Ryan have
->been talking
->about, but I figured I chime in and share what I have done from
->TripleASP.Net
->
->I still have to clean it up a bit, but here is what I have
->been doing for
->page templates.
->
->I created my own base class from Page. Added a couple of overrideable
->methods with a default layout.
->You can view the code here:
->http://tripleasp.net/showcode/template/templates.cs.code
->
->Next, I created an ASPX page with my sites general layout that I could
->include in any page that needed it (this html/aspx is very IBS like):
->http://tripleasp.net/showcode/template/html.aspx.code . Some
->of the style
->features are still a little too "hard coded", but for my
->needs this was OK.
->
->>From here, to add a new page to the site, I simply include
->the html.aspx
->page and inhert from my template class:
->http://tripleasp.net/showcode/template/article.aspx.code and
->http://tripleasp.net/showcode/template/article.aspx.cs.code
->
->Or, as you might have seen in the templates.cs.code link, I
->created a couple
->of default pages that inhert directly from my template class.
->So inorder to
->build my about page, (http://TripleASP.Net/About.aspx) all I
->had to do is
->inherit from my simplecontent class:
->http://tripleasp.net/showcode/template/about.aspx.cs.code
->
->If anyone is interested, I can put some kind of download
->and/or article
->together on this.
->
->-Scott
->
->-----Original Message-----
->From: Ryan Trudelle-Schwarz [mailto:Click here to reveal e-mail address]
->Sent: Thursday, May 16, 2002 10:23 AM
->To: aspngreuse
->Subject: [aspngreuse] RE: Page Templating
->
->
->Sounds good. Personally I don't think I'll ever use the ~ notation but
->others might.
->
->Along with this, does anyone have any fully working samples of this
->technique for page templating? Would be nice if we could post
->those for
->others to see.
->
->Thanks, Ryan
->
->-----Original Message-----
->From: Ollie Cornes [mailto:Click here to reveal e-mail address]
->
->If you want to add support for "~/", you can pass the
->template/stylesheet
->path through this method:
->
->private string ProcessWebPath(string path)
->{
-> if (path.StartsWith("~/"))
-> {
-> return HttpContext.Current.Request.ApplicationPath + "/" +
->path.Substring(2); } else {
-> return path;
-> }
->}
->
->I was thinking about how it could be extended for multiple
->templates in a
->site. Then, for any given page, it's possible to do something
->like this in
->the Page_Load:
->
->this.Template = "RedBackground"; // choose the template for this page
->this.Title = "My demonstration page"; // override default title
->
->In the web.config you could then have:
->
-><add key="RedBackground_Template" value="~/TemplateR.ascx"/> <add
->key="RedBackground_Stylesheet" value="~/stylesR.css" /> <add
->key="RedBackground_DefaultTitle" value="My Red Page" /> <add
->key="BlueBackground_Template" value="~/TemplateB.ascx"/> <add
->key="BlueBackground_Stylesheet" value="~/stylesB.css" /> <add
->key="BlueBackground_DefaultTitle" value="My Blue Page" />
->
->(maybe use a hierarchical structure for this?)
->
->And as an added bonus, as the template uses codebehind, it
->can do its own
->checks. For example a template could decide only show a
->certain UI object
->(advert, navigation, etc) in specific areas of the site. e.g.
->an e-commerce
->site wouldn't want to show a "Buy Now!" banner during the
->shopping process.
->
->Ryan, I'll lend a hand with this if you like. I'd love to see
->this developed
->as it's a MUCH better way to handle the templating problems
->most of us face
->when we build sites.
->
->What do you think?
->
->Ollie
->--
->http://www.RichTextBox.com
->The easy way to add formatted text editing to your ASP.NET web site
->
->----- Original Message -----
->From: "Ryan Trudelle-Schwarz" <Click here to reveal e-mail address>
->
->As a friend of mine would say, "Caching hides all sins".
->While I don't agree
->with this completely, it does apply in this circumstance.
->
->As for the technique used in this article... It's ugly to the
->user of the
->template, something that should be avoided if at all
->possible. That's why I
->created a templating scheme of my own.
->(http://www.aspalliance.com/mamanze/articles/default.aspx?path
=pagetemplate)

Many people have been implementing it lately and so far I've only heard good
things about it.

Hth, Ryan

-----Original Message-----
From: Little, Ambrose [mailto:Click here to reveal e-mail address]

Has anyone implemented page templating using the method described in
http://www.fawcette.com/vsm/2001_12/magazine/columns/aspnet/default.asp
(inheriting your code-behind page class from a custom page class using
placeholders, etc.)?

What are the pros/cons of this approach as regards speed (and
maintainability)?

Reply to this message...
 
    
RBFigueira@montepiogeral.pt
Scott,

Have you got any , simple, working sample to share with us ?

We would be very happy with that ;P

Can you share your knowledge with us... please :P

Note: If anyone have tried to use this class (tripleasp.net) and have an
working sample, please share with us !

Ryan: I am using your class ;P Very good one ! If you have made any
improvement, please share with us !

Thanks to all friends ;OP

Best regards,
Ricardo Figueira (RBFIGUEIRA)

-----Original Message-----
From: Scott Watermasysk [mailto:Click here to reveal e-mail address]
Sent: quinta-feira, 16 de Maio de 2002 16:22
To: aspngreuse
Subject: [aspngreuse] RE: Page Templating

I think this differs slightly from what Ollie and Ryan have been talking
about, but I figured I chime in and share what I have done from
TripleASP.Net

I still have to clean it up a bit, but here is what I have been doing for
page templates.

I created my own base class from Page. Added a couple of overrideable
methods with a default layout.
You can view the code here:
http://tripleasp.net/showcode/template/templates.cs.code

Next, I created an ASPX page with my sites general layout that I could
include in any page that needed it (this html/aspx is very IBS like):
http://tripleasp.net/showcode/template/html.aspx.code . Some of the style
features are still a little too "hard coded", but for my needs this was OK.

From here, to add a new page to the site, I simply include the html.aspx
page and inhert from my template class:
http://tripleasp.net/showcode/template/article.aspx.code and
http://tripleasp.net/showcode/template/article.aspx.cs.code

Or, as you might have seen in the templates.cs.code link, I created a couple
of default pages that inhert directly from my template class. So inorder to
build my about page, (http://TripleASP.Net/About.aspx) all I had to do is
inherit from my simplecontent class:
http://tripleasp.net/showcode/template/about.aspx.cs.code

If anyone is interested, I can put some kind of download and/or article
together on this.

-Scott

-----Original Message-----
From: Ryan Trudelle-Schwarz [mailto:Click here to reveal e-mail address]
Sent: Thursday, May 16, 2002 10:23 AM
To: aspngreuse
Subject: [aspngreuse] RE: Page Templating

Sounds good. Personally I don't think I'll ever use the ~ notation but
others might.

Along with this, does anyone have any fully working samples of this
technique for page templating? Would be nice if we could post those for
others to see.

Thanks, Ryan

-----Original Message-----
From: Ollie Cornes [mailto:Click here to reveal e-mail address]

If you want to add support for "~/", you can pass the template/stylesheet
path through this method:

private string ProcessWebPath(string path)
{
if (path.StartsWith("~/"))
{
return HttpContext.Current.Request.ApplicationPath + "/" +
path.Substring(2); } else {
return path;
}
}

I was thinking about how it could be extended for multiple templates in a
site. Then, for any given page, it's possible to do something like this in
the Page_Load:

this.Template = "RedBackground"; // choose the template for this page
this.Title = "My demonstration page"; // override default title

In the web.config you could then have:

<add key="RedBackground_Template" value="~/TemplateR.ascx"/> <add
key="RedBackground_Stylesheet" value="~/stylesR.css" /> <add
key="RedBackground_DefaultTitle" value="My Red Page" /> <add
key="BlueBackground_Template" value="~/TemplateB.ascx"/> <add
key="BlueBackground_Stylesheet" value="~/stylesB.css" /> <add
key="BlueBackground_DefaultTitle" value="My Blue Page" />

(maybe use a hierarchical structure for this?)

And as an added bonus, as the template uses codebehind, it can do its own
checks. For example a template could decide only show a certain UI object
(advert, navigation, etc) in specific areas of the site. e.g. an e-commerce
site wouldn't want to show a "Buy Now!" banner during the shopping process.

Ryan, I'll lend a hand with this if you like. I'd love to see this developed
as it's a MUCH better way to handle the templating problems most of us face
when we build sites.

What do you think?

Ollie
--
http://www.RichTextBox.com
The easy way to add formatted text editing to your ASP.NET web site

----- Original Message -----
From: "Ryan Trudelle-Schwarz" <Click here to reveal e-mail address>

As a friend of mine would say, "Caching hides all sins". While I don't agree
with this completely, it does apply in this circumstance.

As for the technique used in this article... It's ugly to the user of the
template, something that should be avoided if at all possible. That's why I
created a templating scheme of my own.
(http://www.aspalliance.com/mamanze/articles/default.aspx?path=pagetemplate)

Many people have been implementing it lately and so far I've only heard good
things about it.

Hth, Ryan

-----Original Message-----
From: Little, Ambrose [mailto:Click here to reveal e-mail address]

Has anyone implemented page templating using the method described in
http://www.fawcette.com/vsm/2001_12/magazine/columns/aspnet/default.asp
(inheriting your code-behind page class from a custom page class using
placeholders, etc.)?

What are the pros/cons of this approach as regards speed (and
maintainability)?

It's sounds cool, except it seems that for every page you'd have to have an
ASPX that inherits from the custom template and sets up the various reusable
stuff, and then you'd have to have an ASCX for every ASPX containing the
body stuff particular to that page. Seems a little redundant, and I'm not
sure what it has to offer over just putting the controls on each ASPX page
and using includes for the basic HTML structure.

In addition, it seems like it may add some overhead in loading extra
controls for the page. So any thoughts are appreciated.

--Ambrose

---
[This E-mail scanned for viruses by Declude Virus]

| [aspngreuse] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngreuse.asp = JOIN/QUIT

| [aspngreuse] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngreuse.asp = JOIN/QUIT

Reply to this message...
 
    
RBFigueira@montepiogeral.pt
Good morning Friends,

Anyone have found what this functions do ? :

- FindControl
ex: FindControl("BottomPanel").Controls.Add(uc);

- TANConfig
ex: if(TANConfig.CacheSettings[controlname].Seconds > 0)

Thanks ;P

Best regards,
Ricardo Figueira (RBFIGUEIRA)

-----Original Message-----
From: Ricardo Barros Figueira
Sent: sexta-feira, 24 de Maio de 2002 10:22
To: aspngreuse
Subject: [aspngreuse] RE: Page Templating

Scott,

Have you got any , simple, working sample to share with us ?

We would be very happy with that ;P

Can you share your knowledge with us... please :P

Note: If anyone have tried to use this class (tripleasp.net) and have an
working sample, please share with us !

Ryan: I am using your class ;P Very good one ! If you have made any
improvement, please share with us !

Thanks to all friends ;OP

Best regards,
Ricardo Figueira (RBFIGUEIRA)

-----Original Message-----
From: Scott Watermasysk [mailto:Click here to reveal e-mail address]
Sent: quinta-feira, 16 de Maio de 2002 16:22
To: aspngreuse
Subject: [aspngreuse] RE: Page Templating

I think this differs slightly from what Ollie and Ryan have been talking
about, but I figured I chime in and share what I have done from
TripleASP.Net

I still have to clean it up a bit, but here is what I have been doing for
page templates.

I created my own base class from Page. Added a couple of overrideable
methods with a default layout.
You can view the code here:
http://tripleasp.net/showcode/template/templates.cs.code

Next, I created an ASPX page with my sites general layout that I could
include in any page that needed it (this html/aspx is very IBS like):
http://tripleasp.net/showcode/template/html.aspx.code . Some of the style
features are still a little too "hard coded", but for my needs this was OK.

From here, to add a new page to the site, I simply include the html.aspx
page and inhert from my template class:
http://tripleasp.net/showcode/template/article.aspx.code and
http://tripleasp.net/showcode/template/article.aspx.cs.code

Or, as you might have seen in the templates.cs.code link, I created a couple
of default pages that inhert directly from my template class. So inorder to
build my about page, (http://TripleASP.Net/About.aspx) all I had to do is
inherit from my simplecontent class:
http://tripleasp.net/showcode/template/about.aspx.cs.code

If anyone is interested, I can put some kind of download and/or article
together on this.

-Scott

-----Original Message-----
From: Ryan Trudelle-Schwarz [mailto:Click here to reveal e-mail address]
Sent: Thursday, May 16, 2002 10:23 AM
To: aspngreuse
Subject: [aspngreuse] RE: Page Templating

Sounds good. Personally I don't think I'll ever use the ~ notation but
others might.

Along with this, does anyone have any fully working samples of this
technique for page templating? Would be nice if we could post those for
others to see.

Thanks, Ryan

-----Original Message-----
From: Ollie Cornes [mailto:Click here to reveal e-mail address]

If you want to add support for "~/", you can pass the template/stylesheet
path through this method:

private string ProcessWebPath(string path)
{
if (path.StartsWith("~/"))
{
return HttpContext.Current.Request.ApplicationPath + "/" +
path.Substring(2); } else {
return path;
}
}

I was thinking about how it could be extended for multiple templates in a
site. Then, for any given page, it's possible to do something like this in
the Page_Load:

this.Template = "RedBackground"; // choose the template for this page
this.Title = "My demonstration page"; // override default title

In the web.config you could then have:

<add key="RedBackground_Template" value="~/TemplateR.ascx"/> <add
key="RedBackground_Stylesheet" value="~/stylesR.css" /> <add
key="RedBackground_DefaultTitle" value="My Red Page" /> <add
key="BlueBackground_Template" value="~/TemplateB.ascx"/> <add
key="BlueBackground_Stylesheet" value="~/stylesB.css" /> <add
key="BlueBackground_DefaultTitle" value="My Blue Page" />

(maybe use a hierarchical structure for this?)

And as an added bonus, as the template uses codebehind, it can do its own
checks. For example a template could decide only show a certain UI object
(advert, navigation, etc) in specific areas of the site. e.g. an e-commerce
site wouldn't want to show a "Buy Now!" banner during the shopping process.

Ryan, I'll lend a hand with this if you like. I'd love to see this developed
as it's a MUCH better way to handle the templating problems most of us face
when we build sites.

What do you think?

Ollie
--
http://www.RichTextBox.com
The easy way to add formatted text editing to your ASP.NET web site

----- Original Message -----
From: "Ryan Trudelle-Schwarz" <Click here to reveal e-mail address>

As a friend of mine would say, "Caching hides all sins". While I don't agree
with this completely, it does apply in this circumstance.

As for the technique used in this article... It's ugly to the user of the
template, something that should be avoided if at all possible. That's why I
created a templating scheme of my own.
(http://www.aspalliance.com/mamanze/articles/default.aspx?path=pagetemplate)

Many people have been implementing it lately and so far I've only heard good
things about it.

Hth, Ryan

-----Original Message-----
From: Little, Ambrose [mailto:Click here to reveal e-mail address]

Has anyone implemented page templating using the method described in
http://www.fawcette.com/vsm/2001_12/magazine/columns/aspnet/default.asp
(inheriting your code-behind page class from a custom page class using
placeholders, etc.)?

What are the pros/cons of this approach as regards speed (and
maintainability)?

It's sounds cool, except it seems that for every page you'd have to have an
ASPX that inherits from the custom template and sets up the various reusable
stuff, and then you'd have to have an ASCX for every ASPX containing the
body stuff particular to that page. Seems a little redundant, and I'm not
sure what it has to offer over just putting the controls on each ASPX page
and using includes for the basic HTML structure.

In addition, it seems like it may add some overhead in loading extra
controls for the page. So any thoughts are appreciated.

--Ambrose

---
[This E-mail scanned for viruses by Declude Virus]

| [aspngreuse] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngreuse.asp = JOIN/QUIT

| [aspngreuse] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngreuse.asp = JOIN/QUIT

| [aspngreuse] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngreuse.asp = JOIN/QUIT

Reply to this message...
 
    
Patrik Walther
Hi Scott
This looks very good. Did you 'put some kind of download and/or article
together on this', and if yes where can I find it.

Regards
Patrik

-----Original Message-----
From: Scott Watermasysk [mailto:Click here to reveal e-mail address]

Sent: Donnerstag, 16. Mai 2002 17:22
To: aspngreuse
Subject: [aspngreuse] RE: Page Templating

I think this differs slightly from what Ollie and Ryan have been talking
about, but I figured I chime in and share what I have done from
TripleASP.Net

I still have to clean it up a bit, but here is what I have been doing
for page templates.

I created my own base class from Page. Added a couple of overrideable
methods with a default layout. You can view the code here:
http://tripleasp.net/showcode/template/templates.cs.code

Next, I created an ASPX page with my sites general layout that I could
include in any page that needed it (this html/aspx is very IBS like):
http://tripleasp.net/showcode/template/html.aspx.code . Some of the
style features are still a little too "hard coded", but for my needs
this was OK.

[Original message clipped]

http://tripleasp.net/showcode/template/article.aspx.code and
http://tripleasp.net/showcode/template/article.aspx.cs.code

Or, as you might have seen in the templates.cs.code link, I created a
couple of default pages that inhert directly from my template class. So
inorder to build my about page, (http://TripleASP.Net/About.aspx) all I
had to do is inherit from my simplecontent class:
http://tripleasp.net/showcode/template/about.aspx.cs.code

If anyone is interested, I can put some kind of download and/or article
together on this.

-Scott

-----Original Message-----
From: Ryan Trudelle-Schwarz [mailto:Click here to reveal e-mail address]
Sent: Thursday, May 16, 2002 10:23 AM
To: aspngreuse
Subject: [aspngreuse] RE: Page Templating

Sounds good. Personally I don't think I'll ever use the ~ notation but
others might.

Along with this, does anyone have any fully working samples of this
technique for page templating? Would be nice if we could post those for
others to see.

Thanks, Ryan

-----Original Message-----
From: Ollie Cornes [mailto:Click here to reveal e-mail address]

If you want to add support for "~/", you can pass the
template/stylesheet path through this method:

private string ProcessWebPath(string path)
{
if (path.StartsWith("~/"))
{
return HttpContext.Current.Request.ApplicationPath + "/" +
path.Substring(2); } else {
return path;
}
}

I was thinking about how it could be extended for multiple templates in
a site. Then, for any given page, it's possible to do something like
this in the Page_Load:

this.Template = "RedBackground"; // choose the template for this page
this.Title = "My demonstration page"; // override default title

In the web.config you could then have:

<add key="RedBackground_Template" value="~/TemplateR.ascx"/> <add
key="RedBackground_Stylesheet" value="~/stylesR.css" /> <add
key="RedBackground_DefaultTitle" value="My Red Page" /> <add
key="BlueBackground_Template" value="~/TemplateB.ascx"/> <add
key="BlueBackground_Stylesheet" value="~/stylesB.css" /> <add
key="BlueBackground_DefaultTitle" value="My Blue Page" />

(maybe use a hierarchical structure for this?)

And as an added bonus, as the template uses codebehind, it can do its
own checks. For example a template could decide only show a certain UI
object (advert, navigation, etc) in specific areas of the site. e.g. an
e-commerce site wouldn't want to show a "Buy Now!" banner during the
shopping process.

Ryan, I'll lend a hand with this if you like. I'd love to see this
developed as it's a MUCH better way to handle the templating problems
most of us face when we build sites.

What do you think?

Ollie
--
http://www.RichTextBox.com
The easy way to add formatted text editing to your ASP.NET web site

----- Original Message -----
From: "Ryan Trudelle-Schwarz" <Click here to reveal e-mail address>

As a friend of mine would say, "Caching hides all sins". While I don't
agree with this completely, it does apply in this circumstance.

As for the technique used in this article... It's ugly to the user of
the template, something that should be avoided if at all possible.
That's why I created a templating scheme of my own.
(http://www.aspalliance.com/mamanze/articles/default.aspx?path=pagetempl
ate)

Many people have been implementing it lately and so far I've only heard
good things about it.

Hth, Ryan

-----Original Message-----
From: Little, Ambrose [mailto:Click here to reveal e-mail address]

Has anyone implemented page templating using the method described in
http://www.fawcette.com/vsm/2001_12/magazine/columns/aspnet/default.asp
(inheriting your code-behind page class from a custom page class using
placeholders, etc.)?

What are the pros/cons of this approach as regards speed (and
maintainability)?

It's sounds cool, except it seems that for every page you'd have to have
an ASPX that inherits from the custom template and sets up the various
reusable stuff, and then you'd have to have an ASCX for every ASPX
containing the body stuff particular to that page. Seems a little
redundant, and I'm not sure what it has to offer over just putting the
controls on each ASPX page and using includes for the basic HTML
structure.

In addition, it seems like it may add some overhead in loading extra
controls for the page. So any thoughts are appreciated.

--Ambrose

---
[This E-mail scanned for viruses by Declude Virus]

| [aspngreuse] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngreuse.asp = JOIN/QUIT

| [aspngreuse] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/aspngreuse.asp = JOIN/QUIT

Reply to this message...
 
 
System.Web.HttpContext
System.Web.UI.WebControls.PlaceHolder




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification