1

I need to use the asp control "ImageButton" in order to have access to the properties "OnClick" and "OnClientClick"

The problem is i cannot give any ImageURL since my Image is in Database.

I used this previously :

              <telerik:RadBinaryImage runat="server" ID="RadBinaryImage1" DataValue='<%#Eval("Image") %>'
                    AutoAdjustImageControlSize="false" Width="90px" Height="110px"  Enabled="true"  AlternateText="pas d'image"/>

But i don't have any Datavalue property in ImageButton control...

How can i manage to do this using ImageButton? thanks in advance

3 Answers3

2

You can use a Generic Handler file and call that as your ImageUrl like:

<asp:ImageButton ImageUrl='<%# String.Format("Image.ashx?id={0}", eval("ID")) %>' />

Read more on how to do this here:

http://www.dotnetcurry.com/ShowArticle.aspx?ID=129


The fact its an ImageButton makes no difference. It's the fact you want to render an image from image data type. I believe generating the image on the fly using a Generic Handler file is the most common way.

Curtis
  • 101,612
  • 66
  • 270
  • 352
  • Thanks, Is there any chance to make it work just by including my ImageButton within a LinkButton which has the Click properties ? THX –  Mar 12 '12 at 13:18
0

You can use handler for creating image from database or from binary format and this handler you can call from your imagebutton -> imageURL and it will show the image on the page.

Gaurav Agrawal
  • 4,355
  • 10
  • 42
  • 61
0

You may provide a method that will return an image as stream. Your URL may be:

http://www.yourwebsite.com/Application/Images/GetImage?name=myImageName&format=png

Inside your site you'll provide a GetImage page to query the database and write in the output stream the image data (do not forget to set the mime type).

Adriano Repetti
  • 65,416
  • 20
  • 137
  • 208