Link to home
Start Free TrialLog in
Avatar of bulrick
bulrick

asked on

Images wont show up asp.net visual studio 2008

I am using book: "Beginning ASP.NET 3.5 VB 2008" and following exercises. I cannot get image to show on web page.  Visual Studio 2008  Attachments show code and output.  

I would appreciate your help!


VStudio-code.jpg
Visual-studio02.jpg
Visual-studio03.jpg
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

try use a relative path instead of a full local path.

example, like:

Graph.Src = "~/App_Data/Pic" + Currency.SelectedIndex.ToString + ".png"
Avatar of bulrick
bulrick

ASKER

Using a relative path as you suggested failed to work. I got same result as when using an absolute path. I am using a trial version of Visual Studio 2008.  I wonder if images are disabled in the trial version.
Relative-Path-result.png
Can you try put your images outside of the "App_Data" folder? like in your root application directory, create a folder called as "images", and then point the src to the images in that folder relatively and accordingly?
Avatar of bulrick

ASKER

Thank you..   see attachment ... getting closer to resolution.

I swithched image types to .jpg from .png thinking that might solve problem.  I created a directory outside web like you suggested and it worked fine for an image I got a an email attachement from someone.  However, it would not work for a local jpg file.   I am confused about why this is the case.  
   
Then, I looked at the properties and noticed that the image from my email was "unblocked" .. Not sure why a locked image gets blocked or how to get around this problem.. attachment shows properties of both files.


Image-No-Show-Problem.jpg
Avatar of bulrick

ASKER

I just tried clicking the 'UNBLOCK' button on the properties of the image that worked..(see attachment above).  The 'UNBLOCK' button disappears.  When I run the program the image does not show. This makes sense because its properties match exactly the properties of the other images that do not work.

i.e  If the image comes from another computer then the 'UNBLOCK' button appears in the properties of the image and it shows up finewhen I run the program.  Local jpg images won't show up.

  I do not know how to fix this yet.  Any ideas?
Thanks, Brad
how's your codes look like now? Can you post it here?
Avatar of bulrick

ASKER


  Protected Sub ShowGraph_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ShowGraph.ServerClick
 
        'Graph.Src = "C:\Images\Forest.jpg"    'Fails   
 
        Graph.Src = "C:\Images\bmw02.jpg"   'works fine(has UNBLOCK button in image properties)
 
        'Graph.Src = "C:\Images\bmw01.jpg"  'fails after clicking UNBLOCK in image properties
        'Graph.Src = "~/App_Data/bmw01.jpg"  'fails
 
 
        Graph.Visible = True
    End Sub

Open in new window

As mentioned, try use relative path instead, like:

Graph.Src = "./Images/bmw02.jpg"
Avatar of bulrick

ASKER

Failed using relative page  see code below...
Protected Sub ShowGraph_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ShowGraph.ServerClick
 
        Graph.Src = "./Images/bmw02.jpg"       'Fails 
 
        'Graph.Src = "~/Images/bmw02.jpg"      'Fails
        'Graph.Src = "C:\Images\Forest.jpg"    'Fails 
        'Graph.Src = "C:\Images\bmw02.jpg"          'works fine
        'Graph.Src = "C:\Images\bmw02.jpg"          'works fine(has UNBLOCK button in image properties)
        'Graph.Src = "C:\Images\bmw01.jpg"  'fails after clicking UNBLOCK in image properties
        'Graph.Src = "~/App_Data/bmw01.jpg"
 
 
        Graph.Visible = True
    End Sub

Open in new window

I don't have Visual Studio installed on my home laptop, let me try it on tomorrow when I back to work, I think it's just a path mapping issue, the relative path should resolves your problem. Let me get back to you tomorrow.
Avatar of bulrick

ASKER

thanks you for help....   Look forward to hearing what you discover..

In the mean time I am looking into gpedit.msc to see if something can be set to show images there.
Avatar of bulrick

ASKER

I found the problem with your clues  ..(about relative path methodology . thank you very much!!

 The example code in the book I am using names the subdirectory of the web site "App_Data".
 This is obviously an error in the example code. (At least for the Vista-64 OS version I am using.)

The attachment shows the VS IDE image that shows the working code and Solution Explorer items.

As soon as I hear back from you I will  'Accept  and Award Points'  to you.
Problem-resolved.jpg
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bulrick

ASKER

Given the correct method it was only a matter of trial and error of a few examples.  I did not expect code from a excellent book I am studying to have an example with an error in the naming of a sub-directory.  
That was curve ball.

I appreciate the timely help from ryancys.