Solved

ASP.NET ImageButton Custom Control

Posted on 2010-09-24
9
435 Views
Last Modified: 2013-11-26
Hi I need to create a ASP.NET custom control which is inherited from ImageButton. I need to assign Text Property to it so I can diplay the text on top of the image.

Hope you can help.
0
Comment
Question by:shartan
[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
9 Comments
 
LVL 4

Expert Comment

by:antonybrahin
ID: 33752036
0
 
LVL 1

Expert Comment

by:boogiefromzk
ID: 33752042
Add a property with string type (in fact, I think there already is a caption property) and display it's value in html part as for label control.
0
 

Author Comment

by:shartan
ID: 33752076
Hi Boogiefromzk,

Thanks for the reply. Can you provide me with a sample of what u r suggesting. I am quite new to custom controls.

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

Expert Comment

by:boogiefromzk
ID: 33752267
Sorry, I've went from MS 2 years ago.
See this page for instructons
http://dotnetslackers.com/articles/aspnet/ASPNETCustomControlsPart1.aspx
0
 
LVL 15

Accepted Solution

by:
jorge_toriz earned 500 total points
ID: 33760989
You could use something like this:

public class MyImageButton : ImageButton
{
    protected override void Render(HtmlTextWriter writer)
    {
        writer.Write("<table>");
        writer.Write("<tr><td align=\"center\">");
        writer.Write(Context.Server.HtmlEncode(this.Text));
        writer.Write("</td></tr>");
        writer.Write("<tr><td align=\"center\">");
        base.Render(writer);
        writer.Write("</td></tr>");
        writer.Write("</table>");
    }
}
0
 
LVL 15

Expert Comment

by:jorge_toriz
ID: 33931690
I put a code sample that solves the problem
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

707 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