views:

164

answers:

4

is having different site.master files common practices for theming. right now i have my menu system and different links and styles based on different ".master" files in an asp.net-mvc site. another developer thought that was a strange approach and i wanted to get some thoughts from the community.

A: 

Not that I know a ton about master files, but it seems like it'd be a better idea to use different CSS files for different styles, no?

Esteban Araya
@Estaban Araya - css would be fine if i was just changing colors or slight layout but these different site.master files have a completely different look
ooo
if your HTML is good a completely different look would be no problem with only CSS.
Stefanvds
I agree with Esteban, it is what http://www.csszengarden.com proclaims
uvita
+2  A: 

The most flexible way of "themeing" MVC seems to be providing your own ViewEngine ... this is not as complex as it sounds ... essentially you tell the ViewEngine to look in specified folders for Master Pages and Views .. or to fall back to the default "Views" folder for base implementations ..

For my own implemenation of MVC themes I referred heavily on this article by Christophe Geer: ASP.NET MVC Themed View Engine ... but I am sure there are many other sources available.

JcMalta
A: 

With MVC specifically, then it may make more sense to look a custom view-engine.

With ASP.NET more generally, changing which master page is used programatically is a sensible approach. It is after all why that property can be set at run-time. I do find it irritating that ASP.NET doesn't let you do so unless you start with a reference to an existing file, so unless there's a master page that is going to be used for the vast majority of requests (and can hence be considered a "default") I like to have it start pointed to a text file that just says "dummy text file! will be changed programatically". It makes for a lot less confusion for another developer if they see that than if they see a master page file that doesn't make sense in terms of the output they see.

Coming back to MVC. Since it's a sensible, and quite common, technique in ASP.NET generally, if it meets your needs, then there's no reason not to use it.

Jon Hanna
+1  A: 

I think that having different master pages for different site structures (different HTML, different CSS, ...) is exactly what they are meant for and don't find it strange.

Darin Dimitrov