Apply CSS to Content Page in Asp.NET

前端 未结 3 1780
感情败类
感情败类 2020-12-14 09:07

Normally when we are using Master/Content style pages, we apply the css to Master page so every page child of the master page can use the style but I don\'t want this,I want

相关标签:
3条回答
  • 2020-12-14 09:47

    Normally I put a content placeholder in the head section of the master page. That way any content page can add extra css/js/etc references to the head of the page.

    In your master page put the following

    <head>
      ... title, meta tags, js and css links ...
      <asp:contentPlaceholder id="head" runat="server" />
    </head>
    

    Then in your pages you can include extra elements in the head using this

    <asp:content contentplaceholderid="head" runat="server">
     <link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
    </asp:content>
    
    0 讨论(0)
  • 2020-12-14 09:47

    Put a content placeholder in the head portion of your master page. Not all content pages will need to place anything in it but this particular content page can place the CSS file you want to link.

    0 讨论(0)
  • 2020-12-14 09:49

    You can't apply a style sheet to a content page only, it applies to the whole web page.

    0 讨论(0)
提交回复
热议问题