inheriting/reusing common code

G

Guest

Hi, basic question here - I'm struggling with the transfer from asp to
asp.net a bit, especially in seeing the 'bigger picture' of how things are
best structured.

I have a website made up primarily of aspx pages. I have separated out the
common <head> as an .ascx file and intend to do the same for other common
regions of html.

In the aspx.vb I have code that is common to all pages. For example a sub
which is passed a parameter to tell it the url of the page and builds a menu
with the current page highlighted, and another which passes in Page Title to
the .ascx mentioned above.

Being common code (just the param that varies), I would like to extract
these routines and effectively have one aspx.vb which is common to all aspx
files. How do I do that? All aspx sharing a single codebehind, or at least
inheriting from the common one, and being able to override code in their own
code behind.

Are there any really good books/online tutorials that cover this sort of
architecture planning?

Cheers,

Richard
 
P

Patrice

With 1.1 you can inherit the code (tnot the markup) from another page.
Basically you could have this in a main page class and for other pages
inherits from MyApp.MyPage instead of inheriting from System.Web.UI.Page....

Another option is to look at "masterpages" support. You'll likely find some
controls to add this to 1.1. and it is part of 2.0.

Patrice
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top