开发者

Disaplay Image on screen(Asp.net Mvc) from sql server

From database data is in byte[] array ie. image and I want to show it on screen in image tag 开发者_运维技巧 so decided to write Html helper for image, then How to convert that byte data so that I can assign it to src of img tag


You can also build an aspx page that receive de id of the image in BD as an parameter, this page access you DB, pick the byte[] and just do a response.

Ex.:

In your aspx use like this:

    <img src='<%# "ImageCreator.aspx?id=" + varImageID %>'>

In ImageCreator's Page_Load do this:

    imgID = Request["id"];

    byte[] buffer = ???;//*call something to get this from your DB

    Response.ContentType = "image/gif";
    Response.BinaryWrite(buffer );

Hope this can help you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜