Asp.net dynamically loads CSS

Source: Internet
Author: User

 

If anyone has a more direct method, please kindly advise. I don't know whether. Net can change CSS directly.

<% @ Page Language = " C # " Autoeventwireup = " True " Codefile = " Default. aspx. CS " Inherits = " _ Default "   %>

<!Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

< Html Xmlns = "Http://www.w3.org/1999/xhtml"   >
< Head Runat = "Server" >
< Title > Red solemn </ Title >
< Link Href = "CSS/face_red.css" REL = "Stylesheet" Type = "Text/CSS"   />
< ASP: placeholder Runat = "Server" ID = "PHCSS" > </ ASP: placeholder >
</ Head >
< Body >
< Form ID = "Form1" Runat = "Server" >

</ Form >
</ Body >
</ Html >

Using System;
Using System. Data;
Using System. configuration;
Using System. Web;
Using System. Web. Security;
Using System. Web. UI;
Using System. Web. UI. webcontrols;
Using System. Web. UI. webcontrols. webparts;
Using System. Web. UI. htmlcontrols;

Public   Partial   Class _ Default: system. Web. UI. Page
{
Protected   Void Page_load ( Object Sender, eventargs E)
{
If ( ! Ispostback)
Bindcss ();
}
Private   Void Bindcss ()
{
Htmlgenericcontrol objlink
=   New Htmlgenericcontrol ( " Link " );
Objlink. attributes [
" REL " ] =   " Stylesheet " ;
Objlink. attributes [
" Type " ] =   " Text/CSS " ;
Objlink. attributes [
" Href " ] =   " CSS/common.css " ;
PHCSS. Controls. Add (objlink );
}
}


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.