Opinions please - using placeholders vs inheriting for multiple presentation

Discussion in 'ASP .Net' started by Alan Silver, Jul 24, 2005.

  1. Alan Silver

    Alan Silver Guest

    Hello,

    I am displaying product details on a page and am allowing the site owner
    to specify the style in which the product details are displayed. I am
    debating which of two approaches to use here and would appreciate some
    comments. I intend to write a control that handles the actual display.
    This control would have a method that gets passed the product ID and the
    display style ID. It would pull the product details from a database and
    display them according to the style specified.

    The two current ideas are ...

    1) write a ShowProduct class that handles the work and have various
    ..ascx files inherit this class. That way, each display style can be
    handled by one .ascx file, and they can all have the same named control
    for (say) the product name. This means the class can just set the
    product name control to the right value and know that whichever .ascx is
    being used will display it as it wants.

    2) have just the one .ascx file that handles all display styles. This
    would have a placeholder control for each display style, and would set
    the appropriate one to be visible.

    Any comments? The first approach involves maintaining more files, but
    requires the calling page to work out which control to use and load it
    dynamically at run time. The second approach seems simpler, but would
    require the (say) product name control for each style to be given a
    unique name, resulting in a lot of duplicate code.

    Any comments appreciated. TIA

    --
    Alan Silver
    (anything added below this line is nothing to do with me)
    Alan Silver, Jul 24, 2005
    #1
    1. Advertising

  2. RE: Opinions please - using placeholders vs inheriting for multiple pr

    I would definitely not do the placeholders idea. That (if I understand your
    idea) would make issues come up when you decided to add new styles or styles
    conflict in some way. Having all your eggs in one basket may be difficult to
    manage later.

    The other way seems more work. However, you could minimize a lot of the code
    by making an abstract user control class that each new style inherits. It
    itself would inherit System.Web.UI.UserControl and bring all the behaviors
    with it. Then add .ascx files and change the inheritance from UserControl to
    your new control.

    Does this make sense?
    --
    Clint Hill MCAD
    H3O Software
    http://www.h3osoftware.com


    "Alan Silver" wrote:

    > Hello,
    >
    > I am displaying product details on a page and am allowing the site owner
    > to specify the style in which the product details are displayed. I am
    > debating which of two approaches to use here and would appreciate some
    > comments. I intend to write a control that handles the actual display.
    > This control would have a method that gets passed the product ID and the
    > display style ID. It would pull the product details from a database and
    > display them according to the style specified.
    >
    > The two current ideas are ...
    >
    > 1) write a ShowProduct class that handles the work and have various
    > ..ascx files inherit this class. That way, each display style can be
    > handled by one .ascx file, and they can all have the same named control
    > for (say) the product name. This means the class can just set the
    > product name control to the right value and know that whichever .ascx is
    > being used will display it as it wants.
    >
    > 2) have just the one .ascx file that handles all display styles. This
    > would have a placeholder control for each display style, and would set
    > the appropriate one to be visible.
    >
    > Any comments? The first approach involves maintaining more files, but
    > requires the calling page to work out which control to use and load it
    > dynamically at run time. The second approach seems simpler, but would
    > require the (say) product name control for each style to be given a
    > unique name, resulting in a lot of duplicate code.
    >
    > Any comments appreciated. TIA
    >
    > --
    > Alan Silver
    > (anything added below this line is nothing to do with me)
    >
    =?Utf-8?B?Q2xpbnQgSGlsbA==?=, Jul 24, 2005
    #2
    1. Advertising

  3. Alan Silver

    Alan Silver Guest

    Re: Opinions please - using placeholders vs inheriting for multiple pr

    >I would definitely not do the placeholders idea. That (if I understand your
    >idea) would make issues come up when you decided to add new styles or styles
    >conflict in some way. Having all your eggs in one basket may be difficult to
    >manage later.


    Funnily enough, that's exactly what I found when I tried it!! My initial
    thought was that it was going to be easier than the other approach, but
    it got messy right from the start.

    On the other hand...

    >The other way seems more work. However, you could minimize a lot of the code
    >by making an abstract user control class that each new style inherits. It
    >itself would inherit System.Web.UI.UserControl and bring all the behaviors
    >with it. Then add .ascx files and change the inheritance from UserControl to
    >your new control.


    I tried this yesterday and was amazed at how easy it was. This is the
    first time I've done a class with multiple presentation files, but it
    was really easy to do. The only pain was typing in "protected Label
    lblFerret;" for every control. That took some time, but other than that,
    it was really easy. I can now add extra design styles by simply creating
    a new .ascx file. To save time and errors, I hacked an existing one down
    to just the controls and then rearranged these into a new design.

    >Does this make sense?


    Perfect. I must say I'm constantly knocked out by how powerful ASP.NET
    is. I'm still new enough at it to be very excited (don't worry, I'll
    calm down eventually). I've only been doing it a couple of months, and
    am still finding my way around, but I have become so productive with it,
    that I can't imagine doing any of this in Classic ASP. I'm sure most of
    it could have been done, but I wouldn't like to think how!!

    Thanks for the reply.

    --
    Alan Silver
    (anything added below this line is nothing to do with me)
    Alan Silver, Jul 25, 2005
    #3
  4. Alan Silver

    Clint Hill Guest

    Re: Opinions please - using placeholders vs inheriting for multiplepr

    Glad to help.

    Clint Hill

    Alan Silver wrote:
    >> I would definitely not do the placeholders idea. That (if I understand
    >> your
    >> idea) would make issues come up when you decided to add new styles or
    >> styles
    >> conflict in some way. Having all your eggs in one basket may be
    >> difficult to
    >> manage later.

    >
    >
    > Funnily enough, that's exactly what I found when I tried it!! My initial
    > thought was that it was going to be easier than the other approach, but
    > it got messy right from the start.
    >
    > On the other hand...
    >
    >> The other way seems more work. However, you could minimize a lot of
    >> the code
    >> by making an abstract user control class that each new style inherits. It
    >> itself would inherit System.Web.UI.UserControl and bring all the
    >> behaviors
    >> with it. Then add .ascx files and change the inheritance from
    >> UserControl to
    >> your new control.

    >
    >
    > I tried this yesterday and was amazed at how easy it was. This is the
    > first time I've done a class with multiple presentation files, but it
    > was really easy to do. The only pain was typing in "protected Label
    > lblFerret;" for every control. That took some time, but other than that,
    > it was really easy. I can now add extra design styles by simply creating
    > a new .ascx file. To save time and errors, I hacked an existing one down
    > to just the controls and then rearranged these into a new design.
    >
    >> Does this make sense?

    >
    >
    > Perfect. I must say I'm constantly knocked out by how powerful ASP.NET
    > is. I'm still new enough at it to be very excited (don't worry, I'll
    > calm down eventually). I've only been doing it a couple of months, and
    > am still finding my way around, but I have become so productive with it,
    > that I can't imagine doing any of this in Classic ASP. I'm sure most of
    > it could have been done, but I wouldn't like to think how!!
    >
    > Thanks for the reply.
    >
    Clint Hill, Jul 25, 2005
    #4
    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. Bill Belliveau
    Replies:
    0
    Views:
    359
    Bill Belliveau
    Aug 19, 2003
  2. Colin Basterfield

    PlaceHolders

    Colin Basterfield, Dec 23, 2003, in forum: ASP .Net
    Replies:
    5
    Views:
    596
    Colin Basterfield
    Dec 24, 2003
  3. buran
    Replies:
    1
    Views:
    407
    Bruno Sirianni
    Apr 6, 2004
  4. tshad
    Replies:
    6
    Views:
    484
    tshad
    Aug 1, 2007
  5. Ian Jagger

    using placeholders

    Ian Jagger, Mar 27, 2006, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    168
    Ian Jagger
    Mar 27, 2006
Loading...

Share This Page