Hi thanks, could you post me the opcPageTemplate page to see how I would
have to prototype the base class?
-----Original Message-----
From: Chris [mailto:wrox@d...]
Sent: Thursday, January 16, 2003 8:55 AM
To: ASPX_Professional
Subject: [aspx_professional] RE: template
Apologies if I sent this here already... I did post it somewhere
recently.
One good template approach is described here:
http://www.aspalliance.com/ambrose/Articles/Templating.aspx
In essence, the common parts of your page - header, menu, footer, etc. -
should be constructed as individual user controls (they should probably
be
built that way anyway, even if you weren't using a template.) The user
controls are loaded by the template code you'll find at the above URL,
which
sets up the common areas of the page.
In my current project, each aspx page is about 10 lines of code and
three
lines of script which simply call the appropriate user control to paint
the
body (the non-common area) of the page. In fact, here is one page:
ASPX
<%@ Page Language=3D"vb" AutoEventWireup=3D"false"
Codebehind=3D"docPage.aspx.vb"
Inherits=3D"OPC.Intranet.docPage" %>
<%@ Register TagPrefix=3D"uc1" TagName=3D"docBody"
Src=3D"Components\docBody.ascx"
%>
<uc1:docBody id=3D"docBody" runat=3D"server"></uc1:docBody>
ASPX.VB
Public Class docPage
Inherits opcPageTemplate
Private Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
Handles MyBase.Load
Me.Title =3D "Documents"
Me.StyleSheet =3D "OPCStyles.css"
End Sub
Protected Overrides Sub OnInit(ByVal e As EventArgs)
InitializeComponent()
MyBase.OnInit(e)
End Sub
Private Sub InitializeComponent()
End Sub
End Class
If you're a newbie and thinking, "I don't know how to build user
controls,"
you can learn in 15 minutes... they're essentially just aspx pages with
a
few small bits changed to identify them as user controls. Visit
gotdotnet.com or aspalliance.com or asp.net or other sites for loads of
information about creating and using them.
HTH
-----Original Message-----
From: DT-Rene Vazquez [mailto:renevazquez@c...]
Sent: Wednesday, January 15, 2003 1:37 PM
To: ASPX_Professional
Subject: [aspx_professional] RE: template
Thnaks a lot Andrew I have traed but how I put my pages to inherit from
Template? Simply like this? (MyPage: Template). The template page is in
the
same dll that mMyPage.
-----Original Message-----
From: Andrew Polshaw [mailto:AndrewP@W...]
Sent: Tuesday, December 17, 2002 11:57 PM
To: ASPX_Professional
Subject: [aspx_professional] RE: template
It depends on what you want from a templating system. If it is just
styles,
etc, then use CSS as usual, if there are headers, footers, etc, then one
possibility would be to create a class that derives from Page, e.g.:
public class TemplatePage : System.Web.UI.Page
and then draw the common features on that page. Save this, and then with
your future pages, just get them to inherit from TemplatePage instead,
after
referencing the DLL it is contained within. All controls you defined in
this
template page will be added and you can then just add whatever it is you
need.
-----Original Message-----
From: DT-Rene Vazquez [mailto:renevazquez@c...]
Sent: 18 December 2002 01:24
To: ASPX_Professional
Subject: [aspx_professional] template
Hi all, which is the best way to make a kind of template in asp.net. I
have
a design that is very similar for all of my pages, I want to take this
page
as the base and modify only the desired parts, is this possible?