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)
>