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 Answers 3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, Is there any chance to make it work just by including my ImageButton within a LinkButton which has the Click properties ? THX
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.

Comments

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).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.