Convert from binary data to an image control in ASP.NET

前端 未结 6 1000
傲寒
傲寒 2020-11-27 06:44

I have binary data of an image in my database, and I want to display it in an image control in ASP.NET. How? If it is impossible, please find another way to save it in the d

6条回答
  •  离开以前
    2020-11-27 07:15

    Create a regular HTML img element like so:

    
    

    And in code behind do this:

    image.src = "data:image/png;base64," + Convert.ToBase64String(imageBytes);
    

    Where imageBytes is a byte[].

    You are done. The image will be displayed.

提交回复
热议问题