views:

229

answers:

3

1) If I create a theme and a skin file and a css file to go with that theme, does the skinfile automatically pickup the css file I created? What happens if you have multiple css files under a theme?

2) Do css files in themes override global css files? I created a global one and the theme that had a css file did not change the background color to the one I had in the theme, but the theme that did not have a css file, did change the background color to the one in the global css file.

3) It appears that skins and css files are the same? Can't I just create a theme and use css files within the themes instead of skins? Are skins just for asp.net server controls?

+3  A: 

I dont like skinning and prefer to just use plain ol CSS. Thats precisely what a skin is but very limited. I say drop the skin and stick to CSS files.

JonH
So basically what you are saying is to just create a.css, b.css in a styles folder for example and depending on who is logged in to use the appropriate css file. How do I dynamically change the css file with asp.net? Can you elaborate on what makes a skin limited?
Xaisoft
Yes exactly. Remember asp.net allows you to write code against elements that have runat="server" in them. So make your <link element runat="server". Then in the code you can do something like:myLinkStyleControl.Href="mycssfile.css". You can even pull a css style from a drop down list: myLinkStyleControl.href = ddlCssStyles.SelectedItem.text.
JonH
Where in the code would I change the css file if I did it dynamically?
Xaisoft
That really depends on your application. How do you want to change it via a drop down list? Via a radio button click? Based on a user profile. it all depends. If it is via a drop down list you would use the SelectedIndexChanged event. But again it all depends on how you want to change the CSS file and where you want users to change it at.
JonH
It will be based on the domain, so a.xaisoft.com will get one theme and b.xaisoft.com will get another theme, but for testing purposes, how could I do with a dropdown, meaning, what would my code look like in the selectedindexchaged event if I had a styles folder with a.css and b.css
Xaisoft
If its based on the domain you will want to do it in the Page_Load event.Assume C#: protected void ddlMyDropDown(object sender, EventArgs e) { myLinkStyleControl.Href= "styles/" + ddlMyDropDown.SelectedItem.Text;}
JonH
I am assuming myLinkStyleControl is the link style element in the head section of the page and I am also assuming I need to make this a server-side control in order to access it in page load?
Xaisoft
Ok, that worked so far, I added a link element in the header and left the href blank and then set the style in the page load and it ran succesfully. Now if I wanted to apply this to multiple pages, I probably would have to use a master page or put the link attribute on every aspx page? correct?
Xaisoft
Great glad it ran good. Place the link attribute across all your pages and then set it based on whatever you did before. You can also store the css string in a session that way you can load it in the page load event of all your sub pages within your site. You can change that session variable at anytime as well. Great job :).
JonH
But if I use a masterpage, there is not need to link it to all pages, correct? Thanks for the help by the way.
Xaisoft
That is correct.
JonH
+1  A: 

The Themes in asp.net are a bit confusing, they are somewhat css and a somewhat finicky.

Stick to normal css and create your own skin framework (eg: configured css folder) It will be much easier to use things like jQuery plugins with normal css and it will easier to work with designers who know normal css for cross browser development.

Mark Redman
So don't even bother with an app_themes folder and just uses a styles folder with different css files, is what you are saying, correct?
Xaisoft
Yes, exactly. It took me a while to make this same decision and am glad I did. I expected the Themes Folder to just work as one would expect, but it doesnt really.
Mark Redman
+2  A: 

You can have many theme folders within the App_Themes folder. An ASP.Net Theme can consist of many skin files and many css files.

  1. Yes, the Skin file is aware of the CSS file. When you apply a Theme, your page is made aware of all of the .css files in the Theme automatically.
  2. I'm not sure. Testing is the only way to go.
  3. No, .skin files are different than .css files. Yes, you can just use css files in a theme and skip the skins. Yes, skins are just for asp.net server controls.

Themes vs. Cascading Style Sheets

Themes are similar to cascading style sheets in that both themes and style sheets define a set of common attributes that can be applied to any page. However, themes differ from style sheets in the following ways:

  • Themes can define many properties of a control or page, not just style properties. For example, using themes, you can specify the graphics for a TreeView control, the template layout of a GridView control, and so on.
  • Themes can include graphics.
  • Themes do not cascade the way style sheets do. By default, any property values defined in a theme referenced by a page's Theme property override the property values declaratively set on a control, unless you explicitly apply the theme using the StyleSheetTheme property. For more information, see the Theme Settings Precedence section above.
  • Only one theme can be applied to each page. You cannot apply multiple themes to a page, unlike style sheets where multiple style sheets can be applied.

Quoted from: ASP.NET Themes and Skins Overview


My Opinion:

Generally, if you've got a good understanding of CSS you don't really need .Skin files but Themes are still useful.

Greg
Thanks for the input.
Xaisoft