469,649 Members | 1,239 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,649 developers. It's quick & easy.

inheriting/reusing common code

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
Jul 21 '05 #1
1 1580
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

--

"richardlane" <ri*********@discussions.microsoft.com> a écrit dans le
message de news:2C**********************************@microsof t.com...
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

Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by John M. Gabriele | last post: by
4 posts views Thread by Old Wolf | last post: by
3 posts views Thread by CaribSoft | last post: by
1 post views Thread by richardlane | last post: by
24 posts views Thread by toton | last post: by
2 posts views Thread by brazil.mg.marcus.vinicius.lima | last post: by
4 posts views Thread by AalaarDB | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.