开发者

setting backgroung image to button tag in asp.net

开发者 https://www.devze.com 2023-02-18 03:49 出处:网络
i tried to set image to the button tag in asp.net but it gave an error saying background-image cannot be applied to . Please help

i tried to set image to the button tag in asp.net but it gave an error saying background-image cannot be applied to . Please help I wrote the following code

<asp:Button ID="bsrc" runat="server" Style="left: 545px; position: absolute; top: 18px;font-family:Taho开发者_Go百科ma; font-size:small" Text="Search" Width="101px" />
<img src="search-icon.png" alt="" style="left: 649px; width: 29px; position: absolute; top: 17px; height: 26px" />


There is an asp.net control called ImageButton which looks as though it is what you are wanting to use.

<asp:ImageButton id="bsrc" runat="server" ImageUrl="search-icon.png" />

Rather than using a button and then trying to give it an image.

Edit:

To display text, you can't use the ImageButton. So you will need to use some css to achive the background image of the button.

CSS

.btnstyle1{ background: url(yourimageurl.jpg); height: imageheight; width: imagewidth; }

Button

<asp:Button ID="btn1" runat="server" Text="Button 1" CssClass="btnstyle1" />
0

精彩评论

暂无评论...
验证码 换一张
取 消