Visual inheritance...

  • Thread starter Thread starter Paul M
  • Start date Start date
P

Paul M

Hi folks,

I've got a page that contains the basic formatting that I need for pretty
much all of my systems pages. It's compiled into it's DLL, distributed to
my application's \bin folder and VS allows me to use the class thus :

Public Class Job
Inherits DefaultPage.DefaultPage

The application compiles and runs and is generally happy, but my formatting
isn't there.

There isn't any functionality in the base class, just formatting (header
graphics and couple of hyperlinks).

Can someone point me in the right direction? Is it even possible, or should
I just stick with an HTML includes reference?

Thanks in advance...

P
 
What you want is going to be in ASP.NET 2.0 (Whidbey). For now, you can use
ASCX controls to put in distinct bits of visual information (a control for
the header, a control for the side bar, etc.). You can also pump that in
using the inheritance method, but it's going to be a bit tougher. Remember,
the actual page that is rendered is based on the aspx declarative page,
which inherits from your code behind, which inherits from your base class.
In order to render successfully, you could have something like (VERY much
pseudocode):

page.aspx - inherits from page.aspx.cs:
<asp:PlaceHolder id="header">
my content here
<asp:PlaceHolder id="footer">

page.aspx.cs - inherits from BasePage class
....

BasePage.cs
protected System.Web.UI.WebControls.PlaceHolder header;
protected System.Web.UI.WebControls.PlaceHolder footer;
header.Controls.Add(/* some nice visual bits here */);
footer.Controls.Add(/* some nice visual bits here */);

As you can start to see, you will be doing visual designing without a
designer or even a declarative syntax - not much fun. I would go the ASCX
route until Whidbey comes out. :-)
 
Back
Top