Reputation:
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
Upvotes: 1
Views: 3073
Reputation: 103368
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.
Upvotes: 2
Reputation: 67090
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).
Upvotes: 0
Reputation: 4431
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.
Upvotes: 0