Use CSS in ASP. NET

Source: Internet
Author: User

I thought it would be very troublesome to use CSS in ASP. NET, but it was very easy to do. The usage process is briefly recorded as follows:
CSS can be used in two situations: static addition and dynamic conversion.
1. Static addition:
Add the following content to aspx (add the head tag ):
<Link rel = "stylesheet" href = "pagecss.css" type = "text/css">

Define the pagecss.css file:

P {font-size: 9pt}
A: hover {font-size: 9pt; color: # FF0000; text-decoration: none}
A: link {font-size: 9pt; color: # 0000FF; text-decoration: none}
A: visited {font-size: 9pt; color: #990099; text-decoration: none}
. Button {font-size: 9pt; background: lightgreen; border-color: black; border-width: 1pt; height: 20}

Use CSS to define the style of a button in the aspx file:
<Asp: Button id = "Btn_query" runat = "server" Text = "Search" CssClass = "button"> </asp: Button>

Ii. dynamic transformation:
In asp.net, sometimes CSS needs to be dynamically changed, for example, sometimes personalized pages can be implemented.

1 2 <link id = "MyStyleSheet" rel = "stylesheet" type = "text/css" runat = "server"/>
3 {

MyStyleSheet. Attributes. Add ("href", "/css/flostyle.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.