Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 14th, 2008, 02:15 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hampshire, United Kingdom.
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default Similar Page Content - Making "Generic" Pages

Good morning to you all! I hope/trust all is well? :)

OK, my next problem! :D

We have many pages in our web application that simply is a table of links to other pages, a bulleted menu if you will.

Now, is there a way to make a "one size fits all" page? Coming from Windows development, this is just screaming at me saying "Noooo dont create pages that do the same thing!" and I would simply do something like create a generic form and pass it some arguments to pull the list data.. Is sort of thing possible in ASP.NET?

My current train of thought is to create the "main" page, and then pass it an ID in the QueryString. This ID can then pull the data from a datastore that makes up the actual content, however, this gives me concerns:
  • I would be putting ASP.NET/HTML into a DB, would that be considered "inefficient"?
  • Would ASP.NET Code in the DB actually be passed to the server for processing?
  • Is there a better way!! :)
NOTE: Some of the pages may need slightly different elements (such as an extra button or something).

Any, and all help gratefully received.

Many thanks guys (do we have any female members here?!)

EDIT - Changed Topic title to be more descriptive. Added note on variability.

Rob
http://robzyc.spaces.live.com
__________________
Rob
http://cantgrokwontgrok.blogspot.com
Reply With Quote
  #2 (permalink)  
Old May 14th, 2008, 02:29 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Rob,

This is certainly the correct approach.

I would say there is no harm in putting HTML in your datastore if that is really what the content is. However, if you can provide structure to the data you are showing it would make much more sense to break it down to the data. Then you will have much more control over the display of that data instead of being locked into the HTML that is in the database. This doesn't necessarily require a painful database architecture. You could store more free form XML and use XSLT for display. Store as XML would still allow you to leverage the content as raw data.

How are you going to put ASP.NET code in the database? In .NET there is not a particularly straightforward way of evaluating managed code at runtime. There are ways, but they are by no means efficient without providing some caching mechanism for the result.

Can you provide more detail about what kind of code you want to put in the data store?


-Peter
compiledthoughts.com
Reply With Quote
  #3 (permalink)  
Old May 15th, 2008, 02:23 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hampshire, United Kingdom.
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Peter,

Thanks for the reply, I hope all is well with you.

In terms of the "types" of pages that we have, here are the sort of things we are looking at:
  • A bulleted list of links, which may/may not have some blank items and descriptions for each link.
  • A table of images and text that make up a grid of links (i.e. icons and text). Again, these may have further descriptions/spacing.
  • Data Summary pages, which simply present data from a StProc in a grid that can be sorted and filtered.
  • Record view pages which display data from a particular record from a particular table.
Basically, my current plan is to create a table for each of these "types". For example, the bulleted list will simply contain Text, URL, Description, possibly Order (so we can order lists) and of course ListID. We then pass the ListID in the QueryString for the page, which then pulls the data from this table, in the order specified etc. This one seems fine and is quite simplistic.

TBH, I think most of them are fine, one I have thought about the data and decomposed as necessary. I think the problem comes when I think about flexibility, what do I do when I need to add an additional button in to a specific page?

My thoughts on this are as follows:
  • Add additional field(s) to the tables in question, where HTML can be entered, this is then loaded when the page is loaded. Pretty straightforward and simple, but only standard HTML could really be used.
  • Possibly create Content placeholders of some sort that can be populated at runtime?
I think the problem is that there is some anti-ASP.NET-ism going on, because in ASP Classic you could simply throw in an If/Else and use includes to populate data based on some logic, this sort of process must surely be available in ASP.NET right it simply just a case of "doing more" and pulling the content inside the If/Else from a DB rather than an include?

Thanks for the help, support and thought-provoking comments :)

Rob
http://robzyc.spaces.live.com
Reply With Quote
  #4 (permalink)  
Old May 15th, 2008, 10:20 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You describe the possibility of adding additional controls to the page based on the content. What will those controls do? It would be difficult to dynamically add controls if you don't have some generic code that would handle their events. If you do have the page code to handle events, then what's the point of the additional controls? It's beginning to sound like you are trying to find some middle ground between pure content authoring and technical development of pages.

-Peter
compiledthoughts.com
Reply With Quote
  #5 (permalink)  
Old May 16th, 2008, 03:31 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hampshire, United Kingdom.
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

In terms of the [possible] additional controls, they will most likely simply be links to other areas of the site. So I think simple HTML could be used if need be, since I am trying to keep the UI light on code and push more of the "directing" it to the URL and let the business layer deal with it (hence me trying to come up with these "generic" pages to begin with).

If I simply drop a field in the DB for custom HTML, I could then enter some DIVs/Content in there, which should be rendered OK if we just drop its contents to Response.Write() shouldnt it?

Thanks again for your support :) is is appreciated!

Rob
http://robzyc.spaces.live.com
Reply With Quote
  #6 (permalink)  
Old May 16th, 2008, 08:43 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Yes, however, don't use Response.Write(). You should never need to use Response.Write(). Apart from very basic test pages, I have never found a need to it in 7 years of using ASP.NET.

Instead, put an <asp:literal> on your page. Then you can just assign the value to that. As the name implies, it will show literally what is assigned to it and nothing more. (asp:label wraps the contents of .Text inside a <span> tag which my be undesirable.)

-Peter
compiledthoughts.com
Reply With Quote
  #7 (permalink)  
Old May 16th, 2008, 09:06 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Hampshire, United Kingdom.
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

Excellent, thanks for the heads up in <asp:literal> me being the n00b I am I was unaware of that!

I'll keep you posted! ;)

Thanks again,

Rob
http://robzyc.spaces.live.com
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Master Pages, Content Pages and CSS carliviris Visual Studio 2005 0 January 8th, 2008 05:56 PM
Master Page/Content Pages coleenh ASP.NET 2.0 Basics 1 September 26th, 2006 02:17 PM
Reading similar elements with different content frankstar XSLT 1 July 7th, 2006 01:38 PM
printing 2 similar pages in Crystal reports 8.5 pallavijyo Pro VB 6 0 November 23rd, 2004 12:00 PM
Putting generic content into table rows Blaise XSLT 0 May 21st, 2004 08:29 AM



All times are GMT -4. The time now is 04:44 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.