Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Inherit from ImageButton, add text property

Reply
Thread Tools

Inherit from ImageButton, add text property

 
 
MarkMurphy
Guest
Posts: n/a
 
      07-06-2004
I started searching google, thinking there must be some sample code
about for adding a text property to an ImageButton so that one could
easily localize the button. After thinking about it though, I'm
guessing that one must dynamically generate the image with the text
embedded. Using other various methods might not yield a button-like
behavior when rendered.

Has anyone created a user control that acts like an image button with
a text property?

Thanks,

Mark
 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      07-06-2004
Hi Mark,

AS for the adding a Text Property for the ImageButton. I think you can
consider the following means:
1. Define a own custom ImageButton control which derived from the
ImageButton but it has a TExt property itself and will set the ParentClass
(ImageButton)'s ImageUrl depend on this "Text" property.

2. Build a simple ASP.NET Render control and output the ImageButton's html
source directly. The ImageButton control infact will be output as the
following html source:

<input type="image" name="ImageButton1" id="ImageButton1"
src="http://msdn.micros
oft.com/library/toolbar/3.0/images/banners/msdn_masthead_ltr.gif"
border="0" />

You can directly render out the above things in the control's render method
and if you want to add a property to contorl the ImageUrl, it's also simple
to change the "src" attribute as you like. Do you think so?

Above are some of my suggestions. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx



 
Reply With Quote
 
 
 
 
MarkMurphy
Guest
Posts: n/a
 
      07-07-2004
Hi Steven,

Thanks. I was wanting the text property to contain text to be written
on top of the image. Font properties would be needed as well of
course. I guess the first question is how would look in HTML. Once
that is determined, the server control just needs to do the rendering.

Alternately, I wonder if it might be easier to generate custom GIFs
with the text dynamically added at request time. I guess and
HTTPModule would be the method here.

-Mark
 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      07-08-2004
Hi Mark,

Thanks for your followup. From the further description in your last reply,
it seems that what you want is a new dynamically generated Image which also
contains a certain Text you set in the control's property, yes?

If so, I think the first thing is making a ImageGenerator which can
generate a new Image resource dynamically at runtime. Generally, we can
use HttpHandler to provide such a Image Generator which use the GDI+ apis,
here are some tech articles maybe helpful to you:


#Serving Dynamic Content with HTTP Handlers
http://msdn.microsoft.com/library/de...us/dnaspp/html
/httphandl.asp

#HTTP Handlers for Images in ASP.NET
http://www.c-sharpcorner.com/Code/20...sForImages.asp

#An ASP.NET thumbnail solution
http://www.codeproject.com/aspnet/thumbtools.asp


Then, you register this Image Handler in your web application and in your
custom ImageButton control, set the ImageUrl as the dynamic generate
Image's url( the url that request the Image handler which return an Image
stream).


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      07-13-2004
Hi Mark,

Have you had a chance to check out the suggestions in my last reply or have
you got any further ideas on this issue? If there're anything else we can
help, please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

 
Reply With Quote
 
MarkMurphy
Guest
Posts: n/a
 
      07-14-2004
I agree with those suggestions. Thanks for checking! Good support!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get text from CheckBox.Text property neilr ASP .Net 1 09-01-2008 01:26 PM
Add new text box after entered text cmgmyr Javascript 1 05-27-2008 04:44 PM
Is there a way to add HTML markup to a Textbox.Text property? =?Utf-8?B?bmhheWRvbg==?= ASP .Net 2 07-20-2006 03:27 PM
DataBinder.Eval for an object's property property... like Eval(Container.DataItem,"Version.Major") Eric Newton ASP .Net 3 04-04-2005 10:11 PM
inherit and overwrite a property (better its method call) chris Python 2 03-01-2004 01:55 AM



Advertisments