views:

602

answers:

3

I am working with the new ASP.NET MVC areas and mixing it with themes. In MVC without areas I used to apply themes by adding

<pages theme="ThemeName" ... > ... </pages>

to the Web.Config in the Views folder, and it worked perfectly. Now that I have an Areas folder, each with its own Web.Config, my theme is only applying to controllers in the non areas controllers (which makes perfect sense). I would like to change the default theme in a single Web.Config, but the only one which encompasses all my folders is in the root, which causes an error when you hit the Default.aspx page.

EDIT: In ASP.NET MVC 2, it turns out they removed the Default.aspx page in the root of the website, making it so you can now specify the theme in the root Web.Config without a problem and it applies to areas as well due to the folder structure.

Aside from this, I don't understand how "themes don't necessarily sit well in the MVC paradigm" either. A major concept in MVC is separation of concerns through layers of abstraction. I don't see any reason why the view can't be abstracted to two separate entities, the data displayed at given point in a user interface and the theme that data is styled to.

I have two questions:

  1. Is it possible to specify the theme in a single Web.Config for this type of project? [Solved in edit.]
  2. Why don't themes sit well in the MVC paradigm?
+1  A: 

Simple.

Themes does not sit well in MVC paradigm because managing themes belongs to presentation layer and UI related stuff should be handled by it exclusively.

When working with themes - you are telling how you are going to show something in Controllers or even Model (i.e. - you create a profile for every user or something) and that's a conflict with mentioned paradigm.

But don't forget that MVC ain't religion.

Arnis L.
+3  A: 

Asp.Net Themes are so tightly integrated into Asp.Net (with many particular hook points: creating profiles mentioned by Arnis; having a <head runat="server"> tag; etc..) that to get it working with MVC requires you to create wiring between the major MVC components which intrinsically goes against MVC's purpose (separation of concerns).

cottsak
Just to add a little thing, the ASP.net MVC story is trying to be more tied to HTML+Javascript+CSS, leaving behind abstractions like ViewState and Themes. You can achieve the same thing with CSS without Themes.
Eduardo Molteni
Are you saying MVC is trying to remove the ASP.NET controls?
NickLarsen
It wont take the web forms controls away from web forms, but mvc does not have 'controls' in the same sense. mvc allows for a more finer grained control over exactly what html/js/css u render to the client. sure there are ways of making this easier but we generally dont call them controls (at least in the web forms sense).
cottsak
A: 

Throw WFVE out. Install Spark. Read docs about theming. Implement. Enjoy.

Neal
Does not answer the question.
Eduardo Molteni
Actually it does - somewhat obliquely though I do admit. Themes sit very well with the MVC paradigm, the WFVE implementation of themes however does not.
Neal
I'm guessing that is the "Web Form View Engine"
Tim Abell