動態載入內容頁的css樣式表

來源:互聯網
上載者:User

要動態載入內容中的樣式表,先要將link設定成伺服器控制項,並通過在後台動態綁定link標籤的href,從而實現動態載入內容頁的樣式表。

主版頁面:

<link type="text/css" rel="stylesheet" href="css/basic.css" id="css" runat="server" />

//主版頁面中的href可寫可不寫,但要在link標籤裡面加上runat="server",並設定link的id以便在後台在能調用

內容頁:

HtmlLink css = Master.FindControl("css") as HtmlLink;
css.Href = stylesheet;

//其中stylesheet是該內容頁的樣式表的地址,是相對於根目錄的地址。如根目錄下的css檔案夾裡面的stylesheet.css,那麼就要寫上"css/stylesheet.css"。

 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.