【问题标题】:Advantage of Using Theme & Skin File over CSS in asp.Net在 asp.Net 中使用主题和皮肤文件优于 CSS 的优势
【发布时间】:2012-03-22 09:14:47
【问题描述】:

我正在用 ASP.Net 开发一个网站.. 像我们在 HTML 中使用的那样,使用带有 SkinFile 或 CSS 的主题来开发样式是否好?

哪个最好?

【问题讨论】:

    标签: asp.net .net themes skin


    【解决方案1】:

    主题与层叠样式表

    主题类似于级联样式表,因为主题和样式表都定义了一组可应用于任何页面的通用属性。但是,主题在以下方面与样式表不同:

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

    Please go to msdn for more detail:

    【讨论】:

    • @Kaf:对不起。我没有检查你的链接。
    【解决方案2】:

    ASP.NET 控件可以使用外观文件设置属性。例如,您可以定义网站上的每个按钮都需要以下属性:

    <asp:Button runat="server" 
      BackColor="Red" 
      ForeColor="White" 
      Font-Name="Arial" 
      Font-Size="9px" />
    

    这是一种为您的网站概括样式的方法,但没有什么是单独使用 CSS 无法完成的。

    【讨论】:

      【解决方案3】:

      关于您的问题,如果您只需要样式,那么我会推荐 CSS 方式,尤其是因为它的性能优势,因为它可以缓存并且不会造成任何开销在服务器中。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多