arrgh, aspx templates.

  • Thread starter Thread starter suzy
  • Start date Start date
S

suzy

this is driving me crazy. i hear so many people telling me page templates
are easy, so why can't i get it to work in a nice way.

i just looked at the following site to find out how to implement page
temlates
(http://authors.aspalliance.com/mamanze/articles/?path=pagetemplate3).

i thought it was working fine, but then i realised it was rendering the
<HTML>, <HEAD>, <TITLE> and <BODY> twice (ie: it puts the source of my
template within the body tag of my aspx source). this is obviously not
good, and causes several problems, one of which is the fact that i can't set
a title to my aspx pages.

i have also seen examples which override the render method (like this:
http://www.devarticles.com/c/a/ASP.NET/Easy-ASP.NET-Page-Templates/1/). but
from my understanding this means that when i override the render method, i
have to write out the html, title and body tags in my c# code and wrap these
around the base.Render command.

this also seems messy because it doesn't seem right to put html code in a c#
class, especially when you are creating several nested tables. but it works
i guess.... except when i try and create html code in my aspx page. my html
source cannot have html, title or body tags because the template takes care
of this. this means i have to start with a table or form tag, etc. vs.net
complains about this saying it needs a parent element. i know this is just a
warning message and doesn't stop it compiling, but there must be a neat way
of doing page templates without such warnings.

i hope this makes sense, can anyone help? please please please!!! :)
 
correction to paragraph 2:

i thought it was working fine, but then i realised it was rendering the
<HTML>, <HEAD>, <TITLE> and <BODY> twice (ie: it puts the source of my
ASPX PAGE within the body tag of my TEMPLATE). this is obviously not
good, and causes several problems, one of which is the fact that i can't
set
a title to my aspx pages.
 
Suzy,

Have you had a look at Paul Wilson's article on Master Pages? This is what I
am using right now.
http://authors.aspalliance.com/PaulWilson/Articles/?id=14

This is really simple. I think the problem you are having is most page
templating I have seen the tags you mention are placed in the template ASCX
not in the ASPX.

With Master Pages you can defined a ContentRegion for the title.

HTH
Brian W
 
Ditto to the suggestion on Paul Wilson's Master Pages. After spending
a ton of time on this, I found that there are a lot of ways to do page
templates, but the one one that I found to work well - Master Pages.

Al Cohen
www.alcohen.com
 
Hi, thanks for that link, it seems to work fine, but the supporting
documentation is not very educational.

I've downloaded the demo and it has some syntax which I haven't seen before,
like:

namespace Wilson.MasterPages

{

[ToolboxData("<{0}:MasterPage runat=server></{0}:MasterPage>"),

ToolboxItem(typeof(WebControlToolboxItem)),

Designer(typeof(ReadWriteControlDesigner))]

public class MasterPage : System.Web.UI.HtmlControls.HtmlContainerControl

{

.... etc...



Is there a better tutorial for master pages?



thanks
 
Back
Top