Reputation: 7170
i would like to make 'skinnable' a web site written in asp.net... I explain: for example, i have a 'div' element, and i would like to define a background-color using a variable, not a fixed value. How can i do ? Css ? Or other tecniques ? Thanks
Upvotes: 2
Views: 377
Reputation: 948
CSS doesn't have programming variable capabilities that you hope to achieve.
However, there is a way to do this with PHP (I know you're looking for .NET solution here, but bear with me)
Basically, you add a line of header text "", save the css with .php extension, and then load the .php in html as css (""). Then you can manipulate variables with PHP.
I don't know anything about .NET, but I believe it should be possible in a similar manner.
Upvotes: 0
Reputation: 415735
You might look at .Less and t4 template package for it:
http://haacked.com/archive/2009/12/02/t4-template-for-less-css.aspx
A lot of good notes in the comments of that link as well, including a visual studio addin.
Upvotes: 2
Reputation: 47585
CSS is exactly what your are looking for.
Keep in mind that when writing your classes and ids you should refer to the element semantically. It means you should NOT choose your names depending on the visual representation of the element.
Wrongs:
Goods:
To be able to skin your page, you'll just need to change your css. Almost all is possible using CSS.
Upvotes: 3
Reputation: 245419
ASP.NET has built-in functionality for Themeing and Skinning:
ASP.NET Themes and Skins - MSDN
You could always roll your own as well. The general idea is that you have a seperate set of CSS for each Theme/Skin and then generate the references dynamically based on what Theme/Skin the user selects.
Upvotes: 2