ASP:Linkbutton with text and image

Hi I want to create a Linkbutton with an image.
I want it to look like this:
(Image)(Text)

I do not want the image to cover the whole button as a background. How would this be done?
Code please.

Thx
o3hAsked:
Who is Participating?
 
hosneylkCommented:
or style="position:relative;top:5px;"
0
 
chandresh43Commented:
<asp:LinkButton ID="lbYear" runat="server" CausesValidation="false">

<asp:Image ID="imgFolder" runat="server" ImageUrl="~/images/folder.jpg" />

<%# Container.DataItem %>

</asp:LinkButton>

Open in new window

0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
o3hAuthor Commented:
Wont that pu the whole image as a background.
I trying to craete a delete button, which first shows a "deleteimage" and the text "Delete"
0
 
hosneylkCommented:
the image control has an imagealign property. but by default it should appear how you want it if you use the code given above.
0
 
Obadiah ChristopherCommented:
Try using CSS
.imgCls
{
background: url(bgimage.jpg) no-repeat;
background-size: 75%;
}
0
 
kovilpattiBaluCommented:
hi,
this works for me..

<table id="tblMain" runat="server">
        <tr>
            <td>
                <asp:LinkButton ID="lbYear" runat="server" CausesValidation="false">
                <asp:Image ID="imgFolder" runat="server" ImageUrl="~/images/DeleteIcon.gif" />
                    Test..
                </asp:LinkButton>            
            </td>
        </tr>
    </table>  
0
 
ErikVBCommented:
DotNetNuke has a server control that combines an imagebutton and a linkbutton. Since the license of DotNetNuke is MIT, you can use the code for your own projects. Have a look here to see how its done: http://dotnetnuke.codeplex.com/SourceControl/changeset/view/55305#545504

the nice thing about this is that its a server control, so you can just use it as any other control (just add it to your toolbox :) )

mind you: the control has minor dependencies on dotnetnuke framework functionality, but you can easily change or remove that.
0
 
o3hAuthor Commented:
kovilpattiBalu: yeah work, but I cant set padding on the image.
I would like to image to appear some pixels further down, ideas?
0
 
hosneylkCommented:
style="padding-top:5px" ?
0
 
o3hAuthor Commented:
Yep, you would think =), but doesnt work.
0
 
hosneylkCommented:
how about style="vertical-align:middle" on the image then?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.