Solved

ASP:Linkbutton with text and image

Posted on 2010-11-14
12
722 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
Comment Utility
<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
Comment Utility
0
 

Author Comment

by:o3h
Comment Utility
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
Comment Utility
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
Comment Utility
Try using CSS
.imgCls
{
background: url(bgimage.jpg) no-repeat;
background-size: 75%;
}
0
 
LVL 7

Expert Comment

by:kovilpattiBalu
Comment Utility
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 6

Expert Comment

by:ErikVB
Comment Utility
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
Comment Utility
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
Comment Utility
style="padding-top:5px" ?
0
 

Author Comment

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

Expert Comment

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

Accepted Solution

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

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

6 Experts available now in Live!

Get 1:1 Help Now