Which is better in asp.net 2.0? - asp.net

Can anyone tell me themes are better or CSS style sheets are better in asp.net for design?
Please explain the concept also with an example.

A theme can specify both .skin files and .css files. So there no reason not to use themes.
As for skins versus css: Go for css if its css'able.

You should combine them. Use your css files in the theme folder for your normal styling of all the html elements in your website (include all the generated elements).
In the skin file of a control, you can set the default css class. Other properties like the layout and default behaviour of the elements (sample: calender control) are editable here too.
Skin files are good for all layout specific configuration you can't easily do with css, but with the .net properties of the controls.

Basically themes is built for server controls. You can not use themes with html controls.
The css is used for server controls,html controls and tags. If you are using only server controls then you can use "theme" because you can enable or disable theme on control basis, page basis and whole website basis.
In my opinion CSS is best way to design website. because after rendering theme it shows the css style with controls and tags.
You can also use "Theme" and "CSS" together.

Same query is avilable at my post at following link.
ASP.NET 2.0, AppTheme: How can we utilize AppTheme in best way for my ASP.NET WEBSITE
It make you happy

Related

ASP.NET Theme on CDN

We want to distribute our .NET Themes out to edge of the Cloud.
However, my research through Google and Help files tells me that ASP.NET Themes (App_Themes) must be served from a physical sub-folder of the web server folder or an IIS virtual directory; ergo: Themes cannot be served from a CDN (we are currently using AWS). This seems a major failing and I hope that I am just going to get flamed for not researching properly, but I have to ask:
Does someone know of a way of serving ASP.NET Themes from a different server (and URI) than the web application that uses the Themes?
(Windows Azure could be a possibility, if it is a/the_only way to achieve this.)
Using themes and skins you primarily style server controls. Then it doesn't make sense to have theme files in CDN, since they are processed by the server.
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.
Source: ASP.NET Themes and Skins

mvc3 razor, CSS in Helper

In an mvc 3 razor project I have a helper which creates a component. I can use this helper to create as many components as I need in the same page.
I have different folders containing css files and their images.
Can I specify the css style of each component from the helper?
i.e #html.MyComponent(100, 200, "pink") will uses the style.css in pink folder.
Ps: I am not using html5 neither css3
If you would use classes instead of files it would be much easier. I would just use different styles for themes. You should look at this question: ASP.NET MVC 3, how to do themes right
ASP.NET MVC 3 Razor: Include JavaScript file in the head tag
I think the same thing can be applied but I don't know if you can do it from a helper.
If you are set on doing it this way - then
You need to select the css file at the top for pink
You need to include all style sheets in loading.
You need to dynamically include style sheets when requested by MyComponent. This is tough as you may end up double including them. You can accomplish this via an ActionFilter to write out the css tags at the end, but this is a hack and I wouldn't recommend it.
Stick with convention and your styles should be requested at the top, so you need to know which styles you are using on the page. Your components shouldn't care about loading a style sheet, it should already be loaded which means you have to make this decision at the top of your page. Since you should already 'know' the names at this point (pink, etc) you can easily write the code at the top to request these files via a simply
<LINK href="#string.Format("/{0}/style.css",YourStyleSheetnameIePinkInThisExample)" rel="stylesheet" type="text/css">

Separate CSS file for ASP.NET web server control

I have a my own custom web server control.
I created separate CSS file with CSS classes description for this control.
I do not want to add tag to all pages where it is used. So, I believe that there is any way to connect CSS file directly to control. Is there any way to do it?
And what is the best method to add styles to web server custom control?
This question might work for you. It's for a Custom Control, not a Server Control, but it would only change the method in which CSS stylesheet is dynamically added (not Page_Init(), but maybe Render()?).
That seems to be the only way: a must always be added, though automatically, if an external CSS stylesheet has to be used.

ASP.NET 2.0, AppTheme: How can we utilize AppTheme in best way for my ASP.NET WEBSITE

I am writing asp.net website which will going to be host on public network. I don't have very much knowledge about AppTheme specially utilizing theme, css and skin in asp.net 2.0.
Previously i have worked with asp and asp.net 1.0 where i only write css class and write attribute class="***" inside every control where i want to have css.
I don;'t know whether this is right practice with asp.net 2.0 because in asp.net 2.0 we have advance features like theme and skins.
So can i have help from you so that i can use theme, css and skin in best way . Also i would like to know how different is using css with asp.net 2.0 AS COMPARE WITH PREVIOUS VERSION.
Themes are made up of a set of elements: skins, cascading style sheets (CSS), images, and other resources. At a minimum, a theme will contain skins. Themes are defined in special directories in your Web site or on your Web server.
Here are some links from MSDN that will help you get started:
ASP.NET Themes and Skins Overview
How to: Define ASP.NET Page Themes
How to: Apply ASP.NET Themes
How to: Apply ASP.NET Themes Programmatically
Walkthrough: Creating User-Selectable Themes
Also, I would recommend Scott Allens article on Themes In ASP.NET 2.0 for a quick overview and some samples:
http://www.odetocode.com/articles/423.aspx
Your work shouldn't change that much (if you're working with a single theme).
Your CSS classes will stay as they are at the moment - they'll be used on the client side
You'll add skin files to your theme - these are used for server control style settings
The main difference is that you're able to define several different themes at the same time. Otherwise it depends on you how simple your HTML is. The best way is to not include any style information inside your ASPX files. You should use only use classes. Everything else should be styled within your CSS files.
Oh and BTW: all your CSS files within your App_Themes/Theme folder will be automagically added to your pages. You don't have to explicitly add them to your Master/Aspx page.

Questions on ASP.NET themes?

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?
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.
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.
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.
I'm not sure. Testing is the only way to go.
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.
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.

Resources