[RESOLVED] New project. Need advice.



This is a 2-part question about dynamic rendering of ASP.Net pages.

In the first part, I want to render a page, but the controls that will define the page will need to be read from a source, e.g., XML, data tables, etc. I know how to use XML and XSLT, so this might be a good option. However, don't jump onto any conclusions before you read part 2.

For part 2, I need a system where the user will define what information will be used to build the page I mentioned above. Sorry if that's was a bit unclear. Here is an example: Let's say I want to sell PC monitors and TV's on my website. My boss will come in, define that the product will be a monitor, can be a brand of Samsung, Sony or Lenovo, size 17", 19" or 21" and then respective prices. Then he will enter another product, this time a TV, with different set of specs: Plasma or LCD, size 42", 46" or 50", comes with a Wi-Fi connection or not, yada yada yada. 

As you can see, the two products are not 100% the same and I don't know anything about them before I render my page. I cannot assume they will have a limited set of specs so creating static content is out of question. With this type of design, if my company wants to sell cell phones in the future, all I need to do is let the boss enter the information about the product and my sales page will render it correctly.

I would like to hear your ideas about how I can design this system so my sales page will read and create the controls, e.g., combobox control for size, checkbox for Wi-Fi connectivity, etc. on the go. I appreciate your help!


I've had to do something similar, in my case each object had a user defined "schema" which could be modified dynamically and then populated from an EAV datasource.  As I had dynamicall generated objects to work with I went with MVC (after modifying the Object.cshtml file to allow "Deep Dive" models).  Mainly this was to force the UI blocks which were used to be independent.

In the webforms worlds, you can do the same thing by dynamically adding usercontrols in the control tree.

I would strongly resist XSLT for presentational purposes as in my experience it becomes a maintenance nightmare (especially with localisation, validation, etc) and only really works for simple static pages which could be delivered much more simply as flat html.

Thank you martincjarvis!

Can the mods please carry this topic to MVC? I guess this belongs there.


Yes, avoid XSLT for those reasons. Use XML by all means, but I'd use LINQ-XML to read the XML and construct custom objects.

Essentially you've two unique things to render: the product (name, description, picture), and specs (again, name, description, picture, etc). I did a similar site years ago, where for the line items (specs) we had a finite set of types, so we just had a data structure like this:

internal class Item
  int ID;
  string Name;
  string Description;
  string imageUrl;
  LineItemType ItemType;
  object Value;


  internal enum LineItemType {ComboBox, ListBox, CheckBox, TextBox };

That sort of thing. Then in the code that constructed the item we had a simple switch statement to check the ItemType and construct the right control type.

We are also using XSLT approch in our projects and and do below :

1) Our stored Procedures returns XML.

2) We uses XSL files as a view where XML can be directly applied to return HTML.

3) We are using XSLTToJSON for JSON Serialization , I would like you to check the performace of this  that It is 200% faster then JSON.net with compiled XSL.

4) With .Net 4.0 supports compiled XSL. The XSL transformation is amazingly fast and  It is powerful enough.


I would say write modullar javascript for different modules for your projects, converts XML into JSON and then you can use KnockOut.js + jQuery templating to create amazingly dynamic, high performance and flexible.


Please let me know, if you need any help on this






thoughts on "[RESOLVED] New project. Need advice."

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>