Solved

ASP:Linkbutton with text and image

Posted on 2010-11-14
12
728 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
 

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

696 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