Asp.net: change the background image of the button control.

Source: Internet
Author: User

The button control is one of the commonly used controls in Asp.net. Usually, you need to use various buttons with background images. Use imagebutton instead of text. It is not general enough and you need to use PS every time, troublesome, while the button does not set the attributes of the background image ...... why can't there be a perfect one,

Can I only write user controls?

No, CSS can be fully implemented. The method is also very simple.

First write style class. Button in Head

<Style type = "text/CSS">
. Button
{
. Button {
Width: 56px;/* Image Width */
Background: url(btn2.jpg) No-repeat left top;/* image path */
Border: none;/* remove the border */
Height: 21px;/* Image Height */
}
}
</Style>

 

Then, when referencing, The cssclass attribute of the set button control is button

OK, is it clear? Haha.

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.