Solved

ASP:Linkbutton with text and image

Posted on 2010-11-14
12
723 Views
Last Modified: 2012-05-10
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
0
Comment
Question by:o3h
  • 4
  • 3
  • 2
  • +3
12 Comments
 
LVL 5

Expert Comment

by:chandresh43
ID: 34130456
<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
 
LVL 5

Expert Comment

by:chandresh43
ID: 34130458
0
 

Author Comment

by:o3h
ID: 34130459
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
 
LVL 10

Expert Comment

by:hosneylk
ID: 34130508
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
 
LVL 20

Expert Comment

by:informaniac
ID: 34131513
Try using CSS
.imgCls
{
background: url(bgimage.jpg) no-repeat;
background-size: 75%;
}
0
 
LVL 7

Expert Comment

by:kovilpattiBalu
ID: 34135038
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Expert Comment

by:ErikVB
ID: 34135119
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
 

Author Comment

by:o3h
ID: 34136634
kovilpattiBalu: yeah work, but I cant set padding on the image.
I would like to image to appear some pixels further down, ideas?
0
 
LVL 10

Expert Comment

by:hosneylk
ID: 34141720
style="padding-top:5px" ?
0
 

Author Comment

by:o3h
ID: 34142953
Yep, you would think =), but doesnt work.
0
 
LVL 10

Expert Comment

by:hosneylk
ID: 34142964
how about style="vertical-align:middle" on the image then?
0
 
LVL 10

Accepted Solution

by:
hosneylk earned 500 total points
ID: 34142981
or style="position:relative;top:5px;"
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now