How do CSS in user controls define

Source: Internet
Author: User

User control If you want to centrally define a similar
<style type= "Text/css" >
. C {border-right:1px #D9AE7F solid;border-bottom:1px #D9AE7F solid;cursor:pointer;font-family:arial;font-weight:bold Height:23px;background: #FFF7DD None repeat scroll 0 0; line-height:20px;}
#ctem TD {Border-bottom:1px solid #F0F0F0; color:black;height:25px;}
#ctem A:link, #cctvitem a:active, #cctvitem a:visited {color:black;text-decoration:none;}
#ctem a:hover {Color:red;text-decoration:underline}
. Tmspan {cursor:pointer;display:inline;width:70px;margin:3px 2px 0px 2px;height:16px;border-left:1px solid #D9AE7F; border-right:1px solid #D9AE7F; border-top:1px solid #D9AE7F; text-align:center;font-weight:bold;}
</style>
What to do with this CSS.

If it is written in the control, does not conform to the specification, although generally also works, but if it is dynamic loading, such as Ajax load the user control, it is not.

If the call page is written in front of the page, of course, it is fine, but the meaning of the control is discounted.

You can use the following methods:

Control code:
Const string STYLE = @ "<style type=" "Text/css" ">
. C {border-right:1px #D9AE7F solid;border-bottom:1px #D9AE7F solid;cursor:pointer;font-family:arial;font-weight:bold Height:23px;background: #FFF7DD None repeat scroll 0 0; line-height:20px;}
#ctem TD {Border-bottom:1px solid #F0F0F0; color:black;height:25px;}
#ctem A:link, #cctvitem a:active, #cctvitem a:visited {color:black;text-decoration:none;}
#ctem a:hover {Color:red;text-decoration:underline}
. Tmspan {cursor:pointer;display:inline;width:70px;margin:3px 2px 0px 2px;height:16px;border-left:1px solid #D9AE7F; border-right:1px solid #D9AE7F; border-top:1px solid #D9AE7F; text-align:center;font-weight:bold;}
</style> ";

protected void Page_Load (object sender, EventArgs e)
{
Controls own CSS
This. PAGE.HEADER.CONTROLS.ADD (New LiteralControl (STYLE));
}

The CSS for this control will appear in the

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.