?
Solved

ASP:Linkbutton with text and image

Posted on 2010-11-14
12
Medium Priority
?
730 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
Technology Partners: 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 2000 total points
ID: 34142981
or style="position:relative;top:5px;"
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

777 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