1

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! :)

2
  • What do you mean by "I can't get the image"? Commented Dec 3, 2013 at 11:32
  • @RoyDictus the image i specified in imageUrl is not showing when I the program is running Commented Dec 3, 2013 at 11:34

1 Answer 1

2

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")
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.