views:

23

answers:

2

I'm working on a site that can be displayed to the user in several different ways, kind of like themes, but more functionality related. So basically, the page you are viewing is in a certain state (based on the user, country etc).

The rendering of the controls on a page will vary a bit depending on the current state, and I want this to be easily configurable. (For state A, hide this field in this control, for state B show this icon etc).

In a standard web site, a control would just access a section in web.config to get the its current configuration, but now I want the control to get different configurations depending on the state the page is in.

Any suggestions on how to implement this?

A: 

Why not just save the relevant UserControl Properties values in a database for each state. This way states can be added or modified on the fly later.

Mark Redman
I would like to avoid having a database for this, I want an easy way for a non-techie persons to modify the current configuration.
Bjorn
If you create a front-end to adjust the database, that would be pretty user-friendly. a Non-techy wouldnt want to adjust a configuration file?
Mark Redman
Its a lot of different type of configuration settings, so that would be a _lot_ of job to create the gui. But thanks for the input.
Bjorn
Another thought: One could create multiple container-usercontrols that contain your control with the specific properties set?
Mark Redman
A: 

I choose to create an interface for getting configuration settings that directly mapped to ConfigurationManager.GetSection(string sectionPath). I then injected (using Spring.Net) a class that used the built in configuration manager, but tried to resolve the section path at different levels depending on the current state.

So it started by trying to get the configuration from "[CurrentState]/Application/MyControlConfiguration", if not found tried the default "Application/MyControlConfiguration". Worked pretty well...

The controls didn't have to be aware that the application can override configuration settings depending on state.

Bjorn