ASP. NET uses C # code to set styles or properties in page elements

Source: Internet
Author: User

adding runat = "server" and id= "MyTag" to the attributes of the HTML element will control the style in the background code by setting the value of the Mytag.style.

For example: On the front page join:

<id= "mydiv"  runat= "Server"></Div >

The background can directly refer to the Mydiv to control the image, such as:

Mydiv. style["width""100px";

1.Style Properties
Cascading style sheets (cascading style sheets CSS) CSS uses its rich properties to define the target tag as a variety of styles, such as the ability to define text size, label position, and so on.

" Display:none "  "display:none"// effect above one control.style["  Height"200px"// This notation requires that height be a property in the CSS, otherwise the code is invalid. 

2.Attributes Properties
The Attributes property is essentially a collection of properties for a server control. This way, you can flexibly set arbitrary attribute values, such as

control.attributes["attribute"]=Value; control.attributes["style""display:none";

ASP. NET uses C # code to set styles or properties in page elements

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.