1

我需要使用 asp 控件“ImageButton”才能访问属性“OnClick”和“OnClientClick”

问题是我不能提供任何 ImageURL,因为我的图像在数据库中。

我以前用过这个:

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

但我在 ImageButton 控件中没有任何 Datavalue 属性...

我怎样才能使用 ImageButton 做到这一点?提前致谢

4

3 回答 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.

于 2012-03-12T11:07:17.140 回答
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.

于 2012-03-12T11:07:09.137 回答
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).

于 2012-03-12T11:07:56.437 回答