且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Aspx页面和母版页中引用CSS工作表

更新时间:2023-12-01 16:44:46

只需添加一个CSS ContentPlaceHolder,默认值即可。

Just add a CSS ContentPlaceHolder with a default value in it.

基本上,将包含您指定为默认值的CSS文件,除非您用子页面中的标记覆盖该占位符。

Basically, the CSS file you specify as default will be included unless you override that placeholder with an tag from a child page.

<head>
    <asp:ContentPlaceHolder ID="Stylesheets" runat="server">
        <link rel="stylesheet" href="/css/master.css" type="text/css" />
    </asp:ContentPlaceHolder>
</head>

然后从使用该母版页的任何页面中,您都可以使用其他样式表简单地覆盖它。

Then from any pages using that Master Page, you can simply override that with a different stylesheet.

关于(示例)AboutUs.aspx

<asp:Content ID="Content1" ContentPlaceHolderID="Stylesheets" runat="server">
    <link rel="stylesheet" href="/css/Style.css" type="text/css" />
</asp:Content>