inheriting/reusing common code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • richardlane

    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
  • Patrice

    #2
    Re: inheriting/reusing common code

    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.P age....

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

    Patrice

    --

    "richardlan e" <richardlane@di scussions.micro soft.com> a écrit dans le
    message de news:2C40BD8E-B7E3-477F-9D0C-CE3459C17DC7@mi crosoft.com...[color=blue]
    > 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[/color]
    menu[color=blue]
    > with the current page highlighted, and another which passes in Page Title[/color]
    to[color=blue]
    > 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[/color]
    aspx[color=blue]
    > 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[/color]
    own[color=blue]
    > code behind.
    >
    > Are there any really good books/online tutorials that cover this sort of
    > architecture planning?
    >
    > Cheers,
    >
    > Richard[/color]


    Comment

    Working...