• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 248
  • Last Modified:

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?
0
SETP
Asked:
SETP
  • 5
  • 4
  • 2
1 Solution
 
spdudeCommented:
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

spdude
0
 
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.
0
 
ptleitchCommented:
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
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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?
0
 
ptleitchCommented:
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?
0
 
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.
0
 
ptleitchCommented:
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?
0
 
ptleitchCommented:
maybe do a build and then run the site
0
 
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.
0
 
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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <img src="App_Data/Logo.JPG" /></div>
    </form>
</body>
</html>
0
 
spdudeCommented:
hi SETP

I think Appdata is special folder in asp.net 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
spdude
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now