Solved

ASP.NET ImageButton Custom Control

Posted on 2010-09-24
9
429 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
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

20 Experts available now in Live!

Get 1:1 Help Now