ASP. NET Dynamic use of CSS

Source: Internet
Author: User

 

ASP. NET uses CSS to implement multiple interfaces.

Method 1:

 

<% @ Page Language = "C #" %>
<% @ Import namespace = "system. Data" %>
<Script language = "C #" runat = "server">
Public void page_load (Object OBJ, eventargs E)
{
// Create a server control.
// The specified tag "Link" initializes a new instance of this type.
Htmlgenericcontrol objlink = new htmlgenericcontrol ("Link ");
Objlink. ID = ID;
Objlink. attributes ["rel"] = "stylesheet ";
Objlink. attributes ["type"] = "text/CSS ";
Objlink. attributes ["href"] = "portal.css ";
// This control does not produce any visible output. It is only used as a container for other controls. You can add, insert, or remove controls in it.
Mycss. Controls. Add (objlink );
}
</SCRIPT>
<HTML>
<Head>
<Title> C # </title>
<Asp: placeholder id = "mycss" runat = "server"> </ASP: placeholder>
</Head>
<Body bgcolor = "# ffcc66" style = "Font: 9pt">
<Form runat = "server">
</Form>
</Body>
</Html>

Method 2:

 

<% @ Page Language = "C #" %>
<SCRIPT runat = "server">

Protected void page_init (Object sender, eventargs E)
{
// Define an htmllink control.
Htmllink myhtmllink = new htmllink ();
Myhtmllink. href = "~ /Stylesheet.css ";
Myhtmllink. Attributes. Add ("rel", "stylesheet ");
Myhtmllink. Attributes. Add ("type", "text/CSS ");

// Add the htmllink to the head section of the page.
Page. header. Controls. Add (myhtmllink );

}
</SCRIPT>

 

 

 

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.