• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 443
  • Last Modified:

ASP.NET ImageButton Custom Control

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
shartan
Asked:
shartan
1 Solution
 
antonybrahinCommented:
0
 
boogiefromzkCommented:
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
 
shartanAuthor Commented:
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!

 
boogiefromzkCommented:
Sorry, I've went from MS 2 years ago.
See this page for instructons
http://dotnetslackers.com/articles/aspnet/ASPNETCustomControlsPart1.aspx
0
 
jorge_torizCommented:
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
 
jorge_torizCommented:
I put a code sample that solves the problem
0

Featured Post

Independent Software Vendors: 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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now