A
Alan Silver
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
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