简体   繁体   中英

Getting img src in code behind vb.net

I have two different types of image tags in asp.net as such

<asp:Image ID="ADimage1"    height="150"  width="150"  src="../img/ProfilePic.png"     
runat="server" />

'binary data as image has been set

<asp:Image ID="ADimage2"    height="150"  width="150"  src="data:image/jpeg;base64,iVBORw0KGg"   runat="server" />

and a vb.net button click as such

  Protected Sub btnUploadClick(sender As Object, e As System.EventArgs) Handles     btnUpload.Click
    'not able to get image url
    Dim imageurl1 As String =ADimage1.ImageUrl

    'not able to get image url
    Dim imageurl2 As String =ADimage2.ImageUrl
 EndSub

I am not able to get image url in the backend. it is vb.net web application . Please help.

You have to set ImageUrl attribure in <asp:Image /> tag, then you will get it by ADimage1.ImageUrl . Use ImageUrl instead of src , as

<asp:Image ID="ADimage1" height="150" width="150" ImageUrl="../img/ProfilePic.png" runat="server" />

OR

Of you want to use src only then do the following to get src value,

Dim imageurl1 As String = ADimage1.Attributes("src").ToString()

Dim imageurl2 As String = ADimage2.Attributes("src").ToString()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM