来自 asp.net 的 .skin 与 .css
asp.net 中 .skin
和 .css
之间的主要区别是什么?
.skin
是 IDE 的新增强。我一直在使用 .css
。 .skin
中可用的内容不是 .css
谢谢, 萨吉
What is the main difference between .skin
and .css
in asp.net?
.skin
is new enhancement of IDE. I have been working with .css
. What is available in .skin
that is not to .css
thanks,
saj
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在外观文件中,您可以设置 ASP.NET 控件的属性。
例如,
应用程序中的所有 TextBox 控件的宽度都是 200。
您可以给它一个名称,并且只有您喜欢的控件可以设置它们以应用皮肤,例如,
现在在网页中添加 TextBox 控件时,您可以设置其 SkinID 为“MultiLineTextBox”
如下所示,
因此它将继承 TextMode 为 MultiLine,高度为 240。
要使用皮肤,您必须在 App_Themes 文件夹下向应用程序添加主题,并在其中添加皮肤文件,现在可以在您必须将页面的 EnableTheming 属性设置为 true,将 StylesheetTheme 或 Theme 设置为您的主题名称。您还可以在配置文件中设置此属性。
在页面aspx中设置主题,
在web.config中设置主题,
In the skin file you can set properties of asp.net controls.
For example,
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,
now in a web page when adds TextBox control you can set its SkinID to be "MultiLineTextBox"
as the following,
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,
Setting the theme in the web.config,
请注意,就这两件事的实际作用而言,存在相当大的差异。 .skin 文件中设置的任何属性都会复制到所有页面控件中。使用级联样式表的一个优点是信息加载并缓存一次。 (并且可以应用于多个网页。)外观文件可能会导致页面膨胀,因为每次呈现页面时,外观文件中设置的所有属性都必须与每个受影响的控件合并。
此外,ASP.NET 主题 .skin 文件的默认行为是覆盖受影响控件的属性(这可能是意外行为)。例如,如果您为
.skin
文件中的所有 ASP:Label 设置Width
属性,则所有使用该外观文件的 ASP:Labels 都将具有其宽度
属性设置为.skin
文件的宽度,无论控件的单独宽度
设置如何。为了避免这种行为,ASP.NET StyleSheetTheme 可用于允许控件级属性覆盖全局 .skin 属性。Note that in terms of what these two things actually do there is a considerable difference. Any properties set in the .skin file are copied out to all of the page controls. An advantage to using Cascading Style Sheets is that the information is loaded and cached once. (and can be applied to multiple web pages.) Skin files can cause page bloat because all the properties set in the skin file must be merged with every affected control every time the page is rendered.
Additionally, the default behavior of the ASP.NET Theme .skin files is to override the properties of the controls being affected (this can be an unexpected behavior). For example, if you set the
Width
property for all ASP:Labels in your.skin
file, all the ASP:Labels that use the skin file will have theirWidth
properties set to that of the.skin
file's regardless of the control's individualWidth
setting. To avoid this behavior, the ASP.NET StyleSheetTheme can be used to allow control-level properties to override the global .skin properties.您甚至可以在 CSS 中设置一些属性,例如宽度。除了能够设置 CSS 无法设置的属性之外,还有一些功能需要 .skin 文件来实现。
考虑一个示例,您需要页面上的所有 asp:Label 控件均为蓝色。 asp:Label 实际上是一个 span 内的文本,位于隐藏的 div 内。这就是为什么我们能够为此 asp:Label 设置一些属性(例如 BackColor),以及为什么标准标签控件没有“BackColor”属性。
因此,如果您尝试通过 CSS 设置所有 ASP 标签的字体颜色,
那么类似的操作
将不起作用。另一方面,使用您可以编写的皮肤文件
,这会将所有标签设置为蓝色。
You can set some properties like Width even in CSS. Apart from being able to set properties that CSS cannot, there are some things you need .skin file for.
Consider an example where you need all the asp:Label controls on your page to be in blue color. A asp:Label is actually text inside a span, thats inside a hidden div. This is why we are able to set some properties like BackColor to this asp:Label and why the standard label control does not have a 'BackColor' property.
So, if you try to set font color to all ASP Labels through CSS,
then something like
Will not work. On the other hand, using a skin file you can write
and this will set all Labels to blue color.