asp.net中css和skin之间有什么区别 [英] What is the difference between css and skin in asp.net

查看:116
本文介绍了asp.net中css和skin之间有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..

我需要知道css和皮肤文件之间的明显区别。

我们可以通过皮肤文件直接应用服务器控件的属性意味着为什么要使用应用程序的css?

解决方案

请参阅 - .skin vs .css from asp。网 [ ^ ]

< blockquote class =FQ>

在skin文件中你可以设置asp.net控件的属性。



例如,

 <   asp:TextBox     runat   =  server   宽度  =  200  /  >  



您所有的TextBox控件应用程序的宽度为200.



你可以给它一个名字,只有你喜欢的控件可以设置它们来应用皮肤,例如,

 <   asp:TextBox     ID   =  MultiLineTextBox     runat   =  server    TextMode   =  MultiLine   高度  =  240  /  >  



现在在网页中添加TextBox控件时可以将其SkinID设置为MultiLineTextBox,如下所示,

 <   asp:TextBox     runat   =  server    SkinID   =  MultiLineTextBox  /  >  



因此它将继承TextMode为MultiLine,将Height继承为240.



要使用皮肤,必须在App_Themes文件夹下为应用程序添加主题,然后在那里添加皮肤文件,现在在你的主题中使用这个主题您必须将页面的EnableTheming属性设置为true,将StylesheetTheme或Theme设置为主题名称的页面。您也可以在配置文件中设置此属性。



在页面aspx中设置主题,

 <%@     Page    语言  =  C#    AutoEventWireup   =   true    CodeBehind  < span class =code-keyword> =  WebForm1.aspx.cs   < span class =code-attribute>继承  =  WebApplication1.WebForm1    Enabl eTheming   =  true   样式表主题  = 您的主题名称   %>  



设置主题web.config,

 <   configuration  >  
< system。网络 >
< styleSheetTheme = 您的主题名称 > < span class =code-keyword>< / pages >
< / system.web >
< / configuration >





更多信息

1. < a href =http://stackoverflow.com/a/4553459> CSS文件与皮肤文件 [ ^ ]

2. .skin vs。 css [ ^ ]。

3. Diiference:皮肤文件和CSS [< a href =http://www.dotnetspider.com/forum/182536-Diifere nce-Skin-file-CSS.aspxtarget =_ blanktitle =New Window> ^ ]


Skins-定义控件的一组属性'外观



层叠样式表(CSS) - 用于定义HTML元素的外观和布局属性的标准



图片 - 定义网站外观的文件,例如公司徽标





主题至少有,一个皮肤文件。皮肤和CSS之间发生了一些重叠,因为它们都用于控制外观。然而,它们有一些重要的区别:



皮肤不会级联。与CSS不同,您可以在其中创建样​​式层次结构,为您在站点上使用的每种控件类型定义一个外观。有关CSS样式级联的更多详细信息,请参阅侧栏级联样式。



外观定义ASP.NET Web服务器控件的属性。 CSS样式适用于HTML元素。



皮肤适用于单个Web服务器控件。样式可以应用于单个HTML元素或元素集合。



样式可用于控制页面元素的位置。









参考此链接 [ ^ ]

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?

解决方案

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


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

For example,

<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,

<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,

<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,

<%@ 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,

<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[^]


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[^]


这篇关于asp.net中css和skin之间有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆