Reputation: 1526
I'm new using VB so maybe someone can help me on my problem..
I'm able to create image button programmatically but I can't get the image ..
Code Below:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
ibtn = New ImageButton
ibtn.ID = "1"
ibtn.ImageUrl = "C:\Users\user\Desktop\red.png"
Panel1.Controls.Add(ibtn)
End Sub
End Class
Advance Thanks! :)
Upvotes: 1
Views: 1622
Reputation: 10122
It is not possible to use Physical image path because it can access only virtual path. You should use the Server.MapPath.
So in order to get this image, copy image into web project and use server.mappath as shown below :
ibtn.ImageUrl = Server.MapPath("[Path]/1.jpg")
Upvotes: 2