【发布时间】:2012-03-22 09:14:47
【问题描述】:
我正在用 ASP.Net 开发一个网站.. 像我们在 HTML 中使用的那样,使用带有 SkinFile 或 CSS 的主题来开发样式是否好?
哪个最好?
【问题讨论】:
我正在用 ASP.Net 开发一个网站.. 像我们在 HTML 中使用的那样,使用带有 SkinFile 或 CSS 的主题来开发样式是否好?
哪个最好?
【问题讨论】:
主题与层叠样式表
主题类似于级联样式表,因为主题和样式表都定义了一组可应用于任何页面的通用属性。但是,主题在以下方面与样式表不同:
* 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.
【讨论】:
ASP.NET 控件可以使用外观文件设置属性。例如,您可以定义网站上的每个按钮都需要以下属性:
<asp:Button runat="server"
BackColor="Red"
ForeColor="White"
Font-Name="Arial"
Font-Size="9px" />
这是一种为您的网站概括样式的方法,但没有什么是单独使用 CSS 无法完成的。
【讨论】:
关于您的问题,如果您只需要样式,那么我会推荐 CSS 方式,尤其是因为它的性能优势,因为它可以缓存并且不会造成任何开销在服务器中。
【讨论】: