ASP.NET Graphics

In Visual Studio Developer 2005 I create a new ASP.NET website. I add a GIF file to the App_Data directory. I drag and drop this GIF file to the Default.aspx file. An <IMG> object is created with the follwing scr property: App_Data/images/Logo.JPG

The HTML code for it looks like this:

<img src="App_Data/images/Logo.JPG" />

I now press F5 to run the site. Internet Explorer 6 launches and loads the page. However, instead of the image, I see a small placeholder for it (the standard IE placeholder when it can't find an image). Why is this?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

well step you have to refresh the folder

go to App_Data  and right click on it and press the refresh folder option

and see if you get image

at first even i was frusted by this behaviour but later got used to it

good luck

SETPAuthor Commented:
Yes, I did refresh the App_Data folder in the Solution Explorer and the image did appear - that's how I was able to drag-and-drop it onto the form. And I can see it on the aspx page in design time perfectly. But as soon as I run the page (using either ASP.NET Development Server or IIS) it doesn't display the images.
Right click on the folder you want the picture in, in solution explorer
select add existing item
browse to your piccy and click ok
drag and drop and asp image control onto your page

<asp:Image ID="imgExample" runat="server" ImageUrl="~/Example/Example.gif" />

click on it in design view and find the Image URL property in the properties toolbox

click once inside that box

then click he button that appears with ... on it

navigate to the folder you added the image to

click ok or something

hope this helps
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

SETPAuthor Commented:
Thanks for the reply ptleitch.

Firstly, if I drag and drop the image from the Solution Explorer onto the form, it creates an HTML img object - not the Image Web Server control. But I did try dragging an Image Web Server control onto the form like you mentioned and following the steps you laid out. Unfortunately, it only displays the pic in design time - not at run time.

Does it work on your computer?
yes it works on my computer.  i could probably help you out if i was sitting right there but oh well.  

by not at run time, do you mean on your local machine?
SETPAuthor Commented:
yes, on my machine. I haven't yet uploaded it to the web server. I'm doing all the testing on my local machine.
paste some of your code, displaying images is a pretty straight forward task, and if it doesn't work, there might be something else wrong, have you gotten any images to show  up at all?
maybe do a build and then run the site

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SETPAuthor Commented:
Do you think it might be a setting in IIS? Although I doubt it cause when I use the ASP.NET Development Server to run it (instead of IIS) it has the same problem.

I tried hard coding the path, as in:

<img src="D:\My Documents\Visual Studio 2005\Web SItes\Info1\App_Data\images\Logo.JPG" />

and then it works (i.e. it displays the image when I run the web site). But this is not an elegant solution, and won't work when I deploy the website.

I've also tried putting a tilde at the beginning of the path, as in

<img src="~App_Data/images/Logo.JPG" />

But it didn't work.
SETPAuthor Commented:
I trtied building the web site - unfortunately it didn't work. I haven;t gotten any images to show unless i hard code the full path. Here is what my .aspx page looks like:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
        <img src="App_Data/Logo.JPG" /></div>

I think Appdata is special folder in 2.0
Which allows you to store only xml ,database , text and report files

Try to create new folder name It Images  and place the image which is in appdata  folder now
Drag and drop the image from images folder in design time and
Run the page

Good luck
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.