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) 4 1366
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)
>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)
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.
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |