Change CSS files dynamically

Source: Internet
Author: User

I encountered this problem yesterday and it is difficult to solve it.
After checking the garden, some other brothers answered this question, but I still don't think it is clear. Here I will summarize it for you.
For example

1 < Link Href = "Addeditpayment.css" Type = "Text/CSS" REL = "Stylesheet" >
2 // For dynamic loading, you need to write this statement again on the page
3 < Link ID = "Cssaddeditpayment" Href = "Addeditpayment.css" Type = "Text/CSS" REL = "Stylesheet" Runat = "Server" />
4 // Please note here/>. If runat = "server" HTML is used, it must end.

Then we add a statement in. CS.

Protected Htmlgenericcontrol cssaddeditpayment;

Perform the following operations during page load:

String Cssfile = Dancepub. getcssname ( " Addeditpayment " ) +   " . CSS " ;
Cssaddeditpayment. Attributes. Add ( " Href " , Cssfile );

here, getcssname is my function, so ignore it
here, all labels on the page can be declared and managed using htmlgenericcontol.
the practice in dnn is similar to this, but for integrity, it is a little troublesome to use.

Related Article

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