0

The following code gets the images name on page load:

   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Dim getImg As New GetImage.SoapClient
            Dim ImageService As New Service.serviceClient
            Dim imageName As String = ImageService.getImgName(imageID)
            Dim binaryImage As Byte() = getImg.getImgDisplay(imageName )
            Image123.ImageUrl = "data:image/png;base64," & imageName 
        End If
    End Sub

            <asp:Image ID="Image123" runat="server" Visible="true" />

In the following line of code I have received the image name "imageName":

  Dim binaryImage As Byte() = getImg.getImgDisplay(imageName )

How can I display this on HTML as it is a byte?

1 Answer 1

1

byte[] is not equal to base64, which is what format the image needs to be if you're trying to embed on the page. You need to convert the byte[] in order to embed the image into the html.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Dim getImg As New GetImage.SoapClient
            Dim ImageService As New Service.serviceClient
            Dim imageName As String = ImageService.getImgName(imageID)
            Dim binaryImage As Byte() = getImg.getImgDisplay(imageName )
            Image123.ImageUrl = "data:image/png;base64," & Convert.ToBase64(binaryImage)
        End If
    End Sub
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.