Click here to Skip to main content
14,971,670 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi..
I need to know the clear difference between css and skin file.
We can apply attributes for server control directly through skin file means why to use css for an application?
Posted
Comments
   
"Difference"... Very incorrect question. This is the same as asking: "what is the difference between operator "if" and .NET assembly", for example.
—SA
Priyaaammu 29-Jan-13 1:58am
   
What is the incorrect thing you find in my question?

Refer - .skin vs .css from asp.net[^]

In the skin file you can set properties of asp.net controls.

For example,
XML
<asp:TextBox runat="server" Width="200"/>

All the TextBox controls in your application will have width 200.

You can give it a name and only the controls you like you can set them to apply a skin for example,
XML
<asp:TextBox ID="MultiLineTextBox" runat="server" TextMode="MultiLine" Height="240"/>

now in a web page when adds TextBox control you can set its SkinID to be "MultiLineTextBox" as the following,
XML
<asp:TextBox runat="server" SkinID="MultiLineTextBox"/>

and thus it will inherit the TextMode as MultiLine and the Height as 240.

To use the skin you have to add a theme to your application under the App_Themes folder and there you add the skin file, now to use this theme in your pages you have to set the EnableTheming property of the page to true, StylesheetTheme or Theme to the name of your theme. You can also set this properties in the config file.

Setting the theme in the page aspx,
XML
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" EnableTheming="true" StylesheetTheme="Your Theme Name" %>

Setting the theme in the web.config,
XML
<configuration>
   <system.web>
     <pages styleSheetTheme="Your Theme Name"></pages>
   </system.web>
</configuration>


More Info
1. CSS files vs skin files[^]
2. .skin vs .css[^].
3. Diiference : Skin file and CSS[^]
Comments
Priyaaammu 29-Jan-13 1:45am
   
Thanks for your comment. My doubt was for example if am having only one label server control in aspx page as
<asp:Label ID="lbl" runat="server" Text="Welcome" SkinID="SkinLabel"> and my skin file is
<asp:Label runat="server" BackColor="Blue" SkinID="SkinLabel"/>.
Here backcolor can be set directly by skin,then why css is needed?
   
Nice question by giving the example.

Difference is written below.
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.

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."

Conclusion
I would suggest to go for CSS instead of skin files. As skin files add extra markup to the page itself making extra overload on the page loading time.
But by CSS all the style definition can go under one external CSS file and it improves performance.
Refer - Improve ASPX web page performance by combining Skin & CSS.
Skins-A set of properties that define a control's appearance

Cascading style sheet (CSS)-A standard for defining the appearance and layout attributes of HTML elements

Images-Files that define the site's appearance, such as company logos


A theme has, at minimum, a skin file. Some overlap occurs between skins and CSS because both are used to control appearance. They have some crucial differences, however:

Skins don't cascade. Unlike with CSS, where you can create a hierarchy of styles, you define one skin for each type of control you use on your site. See the sidebar "Cascading styles" for more details on how CSS styles cascade.

Skins define properties for ASP.NET Web server controls. CSS styles apply to HTML elements.

Skins apply to a single Web server control. Styles can apply to a single HTML element or to collections of elements.

Styles can be used to control the positioning of elements on a page.




Refer this Link[^]
   
v2
Comments
Priyaaammu 29-Jan-13 1:45am
   
Thanks for your comment. My doubt was for example if am having only one label server control in aspx page as
<asp:Label ID="lbl" runat="server" Text="Welcome" SkinID="SkinLabel"> and my skin file is
<asp:Label runat="server" BackColor="Blue" SkinID="SkinLabel"/>.
Here backcolor can be set directly by skin,then why css is needed?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900