Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Opinions please - using placeholders vs inheriting for multiple presentation

Reply
Thread Tools

Opinions please - using placeholders vs inheriting for multiple presentation

 
 
Alan Silver
Guest
Posts: n/a
 
      07-24-2005
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)
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q2xpbnQgSGlsbA==?=
Guest
Posts: n/a
 
      07-24-2005
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)
>

 
Reply With Quote
 
 
 
 
Alan Silver
Guest
Posts: n/a
 
      07-25-2005
>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)
 
Reply With Quote
 
Clint Hill
Guest
Posts: n/a
 
      07-25-2005
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.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Placeholders or One to load controls tshad ASP .Net 6 08-01-2007 03:54 PM
using placeholders Ian Jagger ASP .Net Web Controls 2 03-27-2006 04:42 PM
Selling computer, opinions on presentation Mr Bond NZ Computing 5 12-09-2004 08:17 PM
loading using controls into placeholders buran ASP .Net 1 04-06-2004 05:22 PM
Re: UserControl, user defined property, and placeholders Bill Belliveau ASP .Net 0 08-19-2003 10:13 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57