ASP.NET multiple pages with very similiar layout and logic

Discussion in 'ASP .Net' started by Greg, Mar 26, 2007.

  1. Greg

    Greg Guest

    I have a complex page (with 8 complex user controls, and many other
    asp.net controls.) I have 2 very similiar pages to create, each page
    differing only from the others in one control.

    What is the best way to achieve this? I would guess that I have 3
    alternatives.
    1.) Visual and Logic inheritance. I know absolutely nothing about this
    in ASP.NET, and I haven't found anything that appears immediately
    simple ( i am in a rush to get this job done!).
    2.) Have one page with all the controls on, and pass a parameter in
    the request for the page informing it which identity it should assume
    - i..e. if "PageA" is sent in the page request, the page should behave
    like and contain the controls of a "PageA" type page, etc... This
    would appear simple, though the different pages are to have different
    security permissions - I intended for each page to be in its own
    folder with the web.config file for that folder definining the access
    rights for the logged in user. Having one page to do the work of 3
    would mean that I would have to do the configration work in the top
    level web.config file, which seems a bit more onerous.
    3.) Put the contents of the page I have in now into a user control,
    and put this user control into 3 different pages. My main worry about
    this is the degree of processing overhead involved at the server,
    since the control would be complex (many controls + 8 user controls
    within it). However, it would mean that I could have 3 distinct pages
    that I could more easily apply user access rights to.

    I'm from a winforms background, so a lot of the concepts are quite new
    to me - I'd appreciate any feedback on this.

    Regards,

    Greg.
    Greg, Mar 26, 2007
    #1
    1. Advertising

  2. Greg

    Mark Rae Guest

    "Greg" <> wrote in message
    news:...

    > I'm from a winforms background, so a lot of the concepts are quite new
    > to me - I'd appreciate any feedback on this.


    Sounds like a prime candidate for MasterPages:
    http://www.google.co.uk/search?sour...G,GGLG:2006-28,GGLG:en&q="ASP.NET" MasterPage

    In a nutshell, MasterPages allow the main "look and feel" of a web app to be
    written once only (in the MasterPage itself), and then indivual content
    pages to be created which contain the bits which are different...

    Prior to ASP.NET v2, this sort of functionality was commonly achieved with
    user controls e.g. a user control for the header, a user control for the
    menu, another for the sidebar, maybe another for the footer etc. References
    to these controls needed to be added to each aspx page that required them.

    MasterPages do away with all that. Once the MasterPage is created, simply
    create a new content page and set its MasterPage property - job done.
    Mark Rae, Mar 26, 2007
    #2
    1. Advertising

  3. Greg

    Greg Guest

    On Mar 26, 11:28 am, "Mark Rae" <> wrote:
    > "Greg" <> wrote in message
    >
    > news:...
    >
    > > I'm from a winforms background, so a lot of the concepts are quite new
    > > to me - I'd appreciate any feedback on this.

    >
    > Sounds like a prime candidate for MasterPages:http://www.google.co.uk/search?sourceid=navclient&ie=UTF-8&rls=GGLG,G...
    >
    > In a nutshell, MasterPages allow the main "look and feel" of a web app to be
    > written once only (in the MasterPage itself), and then indivual content
    > pages to be created which contain the bits which are different...
    >
    > Prior to ASP.NET v2, this sort of functionality was commonly achieved with
    > user controls e.g. a user control for the header, a user control for the
    > menu, another for the sidebar, maybe another for the footer etc. References
    > to these controls needed to be added to each aspx page that required them.
    >
    > MasterPages do away with all that. Once the MasterPage is created, simply
    > create a new content page and set its MasterPage property - job done.


    Thanks Mark.

    Under the given circumstances, what advantage would a master page have
    over a user control?

    The control that is different in the 3 pages is half way down the
    page. Would it be necessary to have 2 master pages - i.e. one for the
    top half of controls, and one for the bottom half, and the control
    that is to be different in between?

    Regards,

    Greg.
    Greg, Mar 26, 2007
    #3
  4. Greg

    Mark Rae Guest

    "Greg" <> wrote in message
    news:...

    > Under the given circumstances, what advantage would a master page have
    > over a user control?


    In fact, a MasterPage is nothing more than a user control anyway...

    > The control that is different in the 3 pages is half way down the
    > page.


    OK.

    > Would it be necessary to have 2 master pages - i.e. one for the
    > top half of controls, and one for the bottom half, and the control
    > that is to be different in between?


    Not at all. The MasterPage would contain the "top half" and "bottom half".

    The content pages would contain the content which changes.
    Mark Rae, Mar 26, 2007
    #4
  5. There are 2 ways to achieve this with masterpages.

    1. Have nested master-pages (one within another). You can choose the correct
    master page to suit your needs then. The bad part about this is that you
    won't have any designer support on this.
    2. Have multiple contentplaceholder's in the same master page. That way, at
    every page you can have complete control on what goes into the content, and
    what gets inherited from the masterpage.

    Having mutiple masterpages, for one page is kind of a bad way to program for
    uniform look and feel. I suggest in your case, you may as well use multiple
    contentplaceholder's in the same masterpage.

    Regarding the advantage of masterpages over user-controls, well...all i
    know/can say about masterpages is that its optimized , since its a part of
    the framework. In the past, I have created the master-page as a usercontrol
    (in asp.net 1.1), and the drawback in my code was that for some reason, it
    took longer to render each time, and there was less of
    programmer-friendliness.

    Hope that helps,

    --
    Sashidhar Kokku
    ikaSystems Corp


    "Greg" wrote:

    > On Mar 26, 11:28 am, "Mark Rae" <> wrote:
    > > "Greg" <> wrote in message
    > >
    > > news:...
    > >
    > > > I'm from a winforms background, so a lot of the concepts are quite new
    > > > to me - I'd appreciate any feedback on this.

    > >
    > > Sounds like a prime candidate for MasterPages:http://www.google.co.uk/search?sourceid=navclient&ie=UTF-8&rls=GGLG,G...
    > >
    > > In a nutshell, MasterPages allow the main "look and feel" of a web app to be
    > > written once only (in the MasterPage itself), and then indivual content
    > > pages to be created which contain the bits which are different...
    > >
    > > Prior to ASP.NET v2, this sort of functionality was commonly achieved with
    > > user controls e.g. a user control for the header, a user control for the
    > > menu, another for the sidebar, maybe another for the footer etc. References
    > > to these controls needed to be added to each aspx page that required them.
    > >
    > > MasterPages do away with all that. Once the MasterPage is created, simply
    > > create a new content page and set its MasterPage property - job done.

    >
    > Thanks Mark.
    >
    > Under the given circumstances, what advantage would a master page have
    > over a user control?
    >
    > The control that is different in the 3 pages is half way down the
    > page. Would it be necessary to have 2 master pages - i.e. one for the
    > top half of controls, and one for the bottom half, and the control
    > that is to be different in between?
    >
    > Regards,
    >
    > Greg.
    >
    >
    >
    >
    =?Utf-8?B?U2FzaGlkaGFyIEtva2t1?=, Mar 28, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Lozzi
    Replies:
    0
    Views:
    451
    David Lozzi
    Jul 23, 2005
  2. ted
    Replies:
    1
    Views:
    413
    Dimitre Novatchev [MVP XML]
    Feb 16, 2004
  3. Replies:
    1
    Views:
    563
    John Timney \(MVP\)
    Jun 19, 2006
  4. =?ISO-8859-1?Q?Gregory_Pi=F1ero?=

    Optimize function similiar to dict.update() but adds common values

    =?ISO-8859-1?Q?Gregory_Pi=F1ero?=, Dec 14, 2005, in forum: Python
    Replies:
    10
    Views:
    422
    Peter Otten
    Dec 15, 2005
  5. News123
    Replies:
    1
    Views:
    381
    News123
    Mar 7, 2010
Loading...

Share This Page