Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.Net MVC Themes, how to?

I have a ASP.Net 2.0 site and want to translate it into MVC paradigm (I'm new to this), but starting from Zero.

I have some themes in my old site, but reading here and there, it seems like Themes doesn't fit well into MVC paradigm.

The question is:

What is the best practice in MVC for building a Themed user customizable site? Can you give a little example, if applicable?

Note: I'm aware of this but they don't talk about best practices or how to start with.

like image 394
Jhonny D. Cano -Leftware- Avatar asked Apr 20 '09 20:04

Jhonny D. Cano -Leftware-


People also ask

How can we apply themes in ASP.NET application?

Themes can be applied by using either the Theme or StyleSheetTheme attribute of the @ Page directive, or by setting the pages Element (ASP.NET Settings Schema) element in the application configuration file. Visual Web Developer will only visually represent themes applied by using the StyleSheetTheme attribute.

How do I add themes to Bootswatch?

Type grunt swatch:[theme] to build the CSS for a theme, e.g., grunt swatch:flatly for Flatly. Or type grunt swatch to build them all at once. You can run grunt to start a server, watch for any changes to the SASS files, and automatically build a theme and reload it on change.

How do I add a bootstrap template to Visual Studio?

Installing Bootstrap Bundle This plugin can be downloaded from Visual Studio itself. Just go to Tools, then Extensions and Updates > Online and search for Bootstrap Bundle. Select the plug-in and hit download then install.

What are the topics in MVC?

The topics which I have covered in this tutorial are Controller, View, Routing, Data Sharing from view to controller and controller to view, Razor, HTML Helper Class, Model, Validation, Master Page, Partial View, scaffolding , ajax,area , Authentication, web api etc with example.


2 Answers

Here's my code that I've been using for implementing "Themes" in ASP.NET MVC:

ASP.NET MVC: Implement Theme Folders using a Custom ViewEngine

It's nice when you're able to just swap out CSS files to change the theme, but this really isn't very practical in a ton of cases. Especially when each theme needs to have a completely different layout. In which case, you need to change the CSS and HTML that gets rendered, and this is why I wrote the code found at the above link.

like image 52
Chris Pietschmann Avatar answered Oct 06 '22 22:10

Chris Pietschmann


A clean, semantically correct HTML with a good CSS is the way to theme any web app, whether it's ASP.NET, RoR, PHP, etc.

The best example of the power of CSS is CSS Zen Garden.

w3schools has a nice introduction/tutorial to CSS.

Each of your users could have an associated stylesheet which would get selected whenever applicable, i.e.:

<link rel="stylesheet" type="text/css" href="<%= Model.SelectedStyleSheet %>"/> 
like image 27
Mauricio Scheffer Avatar answered Oct 06 '22 22:10

Mauricio Scheffer