Dynamic Loading of CSS style sheets on content pages

Source: Internet
Author: User

To dynamically load the style sheet in the content, you must first set the link as a server control and dynamically bind the href of the link tag in the background to dynamically load the style sheet of the content page.

Master page:

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

// The href on the master page can be written or not written, but you need to add runat = "server" to the link label, and set the link ID so that it can be called in the background.

Content Page:

Htmllink CSS = Master. findcontrol ("CSS") as htmllink;
CSS. href = stylesheet;

// Stylesheet is the address of the style sheet on the content page, which is relative to the address of the root directory. For example, if stylesheet.css is in the CSS folder under the root directory, you must write "CSS/stylesheet.css ".

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.