473,778 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Opinions please - using placeholders vs inheriting for multiple presentation

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)
Nov 19 '05 #1
4 1381
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.U serControl 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)

Nov 19 '05 #2
>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.U serControl 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)
Nov 19 '05 #3
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.U serControl 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.

Nov 19 '05 #4
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.U serControl 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.

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3679
by: ATK | last post by:
Hi, I'm trying to upload a image file to a oracle DB and i need to only use ODBC functions. In db i have a LONG RAW column (if this is not correct, please tell me). I'm getting the error from oracle: ORA-00972: identifier is too long...
4
18201
by: Rookie | last post by:
I need to display several columns of numbers in a textbox. I wish to display the columns with the decimal point position aligned vertically. I have found that the # digit placeholders do not reserve the spaces for the number if the number of digits are fewer than the number of placeholders. My simplified example: included within a loop such that it displays two columns
16
2493
by: Andy Dingley | last post by:
I've just had a call from these people, http://www.browsealoud.com offering to sell me their wares. Anyone have an opinion on it ? I'll post my own thoughts about 24 hours from now. I'm interested in what others think - wouldn't want to prejudice other's comments.
5
6800
by: adolf garlic | last post by:
Im trying to return xml from sql. The xml is made up of different fragments, some using FOR XML ... syntax. The result is a valid xml doc. There is a working stored proc that returns the xml In .net i'm having problems loading this up. I've now tried installing sqlxml managed classes and the following appears to work when stepping through, but the result just disappears.
2
1900
by: Wysiwyg | last post by:
I was hoping to get some opinions on the efficiency of various methods of reusing the same dropdown list data. Here is the situation: Multiple panels on maintenance pages with TAB menus across the top showing different panels. A DropDownList with a 50+ value/text entries exists on more than one panel but only one will be displayed at a time. Examples might be US states, countries, category codes, etc.
7
1937
by: John | last post by:
Hi all, I need finality on this once and for all please. I have a main page which contains a couple of placeholders and within these placeholders, depending on what the user presses, I load different user controls. This loading of user controls is done within the code-behind of the main page. The problem is that before loading a user control in place of another, I need to do a Controls.Add then a Controls.Remove so the viewstate is...
1
1119
by: Ryan Shaw | last post by:
I’m having trouble with Typed Dataset I would like to add functionality to my typed dataset at the business layer such as delete rules or editing rules by inheriting it Can I inherit the datatable? I’m having trouble because of the constructor Can I override the row change event routines? How do I do that How can I control these features in a typed dataset without my presentation layer having to do it
9
2120
by: Harold Crump | last post by:
Greetings, I have a fairly vanilla PHP web application that stores and retrieves data in a MySQL database. Users will be adding a lot of special characters such as single and double quotes, accented French characters, etc. I want to eliminate any potential for XSS or SQL injection attacks. My question - is it enough to pass all user input through the
112
4760
by: Prisoner at War | last post by:
Friends, your opinions and advice, please: I have a very simple JavaScript image-swap which works on my end but when uploaded to my host at http://buildit.sitesell.com/sunnyside.html does not work. To rule out all possible factors, I made up a dummy page for an index.html to upload, along the lines of <html><head><title></title></ head><body></body></html>.; the image-swap itself is your basic <img src="blah.png"...
0
9629
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9470
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9923
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7475
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6723
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4033
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2865
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.