2

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

2
  • 1
    CSS is usually the way to go for the very majority of visual settings. Commented May 25, 2010 at 18:57
  • check the url posted in answer by me Commented May 25, 2010 at 19:04

4 Answers 4

3

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:

  • .blue
  • boxOnLeft

Goods:

  • .comments
  • related

To be able to skin your page, you'll just need to change your css. Almost all is possible using CSS.

Sign up to request clarification or add additional context in comments.

Comments

2

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.

Comments

2

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.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.