Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

put text in a Imagebutton (beginner)

Status
Not open for further replies.

aspvbnetnerd

Programmer
May 16, 2006
278
SE
I am new to asp.net but is it possible to put text in a imagebutton?
 
You can populate the AlternateText property of the ImageButton so that the text appears when the user mouses over the image, but if you want a combination of image and text, what you want to do is use a LinkButton control like so:

Code:
<asp:LinkButton ID="lbButton" runat="server">
    <img src="MyImage.gif" alt="Whatever" style="border: 0" />
    <br />
    Some Text
</asp:LinkButton>

MCP, MCTS - .NET Framework 2.0 Web Applications
 
BoulderBum, Thanks for the response
With your code the text came below the picture.

I want the text be on the center and on of my picture

Code:
<asp:ImageButton ID="ImageButton1" runat="server" Height="22px" ImageUrl="~/ads.gif"
Style="z-index: 104; left: 35px; position: absolute; top: 343px" Width="186px"
AlternateText="Click Me" />

George
 
Is there a reason not to just PhotoShop text on the picture or dynamically create the image with GDI+?

If you want to do it in HTML (which would NOT be recommended), you could do this:

Code:
<asp:LinkButton ID="lbButton" runat="server">
    <img src="MyImage.gif" alt="Whatever" style="border: 0" />
    <div style="margin-top: -30px; margin-left: 10px">
        Some Text
    </div>
</asp:LinkButton>
{/code]

You can tweak the font size and positioning to taste, but you get the idea.

MCP, MCTS - .NET Framework 2.0 Web Applications
 
BoulderBum, It doesn't become like I want it. The picture I have is like 1 px width.

I am trying to create a webmenu like outlook 2003

I have downloaded the picture Nb-bkgd.gif from
and that is the picture that I am using for my menu.
Now I kneed to set a text for it.

Thanks for putting out with me.

/George
 
Good point ca8msm. The text within the list item could be wrapped by a LinkButton.

Better understanding what you're after, however, I'd highly recommend looking at either the .NET 2.0 TreeView control:


or a third-party solution:


Microsoft's TreeView is part of the free .NET 2.0 framework, and even if you pay $250 for the Telerik control, the time you save in labor and the value you gain in robustness makes the purchase well worth the money.



MCP, MCTS - .NET Framework 2.0 Web Applications
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top