Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a jpg to an aspx page

Status
Not open for further replies.

OhioSteve

MIS
Mar 12, 2002
1,352
US
I am doing a very simple task: adding an image to a web page. I have done this dozens of times. Yet I must be overlooking something obvious, because it does not work.

The graphic is a .jpg. I did this to use it:

1) In Windows, I put it into the project's folder.
2) I right-clicked my project in solution explorer, and I added it.
3) I went to the "web forms" section of the toolbox. I drug an "image" onto the .aspx page.
4) In the image's properties, I clicked the build button ("...") beside "imageUrl". My image was visible in the select image interface. I choose it. The url type was "relative". The url is the jpg's name.
5) I built the project and previewed the web page.
6) I could NOT see the graphic!!
 
What does the source look like for the image once the page has rendered?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
TipGiver:
<asp:Image id="Image1" style="Z-INDEX: 101; LEFT: 200px; POSITION: absolute;
TOP: 128px" runat="server" ImageUrl="logo.jpg"></asp:Image>

ca8msm:
It displays the icon for a missing image, a small red "x" inside two squares.

It is frustrating because the answer must be right in front of me.
 
I usually get the X if I reference a picture in my Images folder with "/images/logo.jpg" ... if I make it look like "images/logo.jpg" I get no red X.
 
I think it's best to kepp all your images in one folder.
heres how I reference an image.

<asp:image id="ImgName" style="Z-INDEX: 103; LEFT: 0px; POSITION: absolute; TOP: 0px" runat="server"
ImageUrl="./images\MyImage.gif"></asp:image>



 
OK, if you want to keep you jog's in your app directory then the image path would be ./Yourimage.jpg

 
yes the ~ will also work. I think the ~ takes you back to the app root no matter how many folders deep you are. I use the . since I have so many folders within folders it's like directory walking in DOS.

 
dvannoy,

I tried your variation and it did not work. I assume you mean the imageURL for a system.web.ui.webControls.image.

In another project, I have a system.web.ui.webControls.image on a web page. It works fine without the ./. It is maddening to see the other one working.
 
it should work with either ./ or the ~

try creating a folder called images, put your image in there and use ./images\image.jpg..

It works for me no problem.

 
Here is a list of everything that I have tried and the results....


1) Is the url correct when I rclick it in solution explorer? Yes
2) Is the security correct? Yes, "everyone" can do anything to it. It does not explicitely give permissions to the user aspnet. However, the other graphic works with the exact same permissions.
3) What application is it associated with? Now this is interesting. It is associated with windows fax/picture viewer. I thought that that might be the problem. However, the other graphic has the same association.
4) Did I include it in my project? Yes
5) Is it under source control, like the other objects in the project? Yes
6) Are you sure about the imageURL setting? Yes. I have just the name right now (it is in my project's main directory). That is the same way I handled the other graphic.
7) What about setting the imageURL to "~/[name]"? I tried that, no change.
8) What about setting the imageURL to "./[name]"? I tried that no change.
9) What about I literal http address, ie " Yes I tried that not change.
10) What happens when you rclick it in sol explorer and choose "view in browser"? It does not appear.
11) What happens when you start IE, use file/open and open it? It opens, but in fax viewer.
12) What about changing the file association? I know you said that the other one had the same association, but still... I tried that no change.
 
one more thing, run the ASPX file in the browser, when the X mark appears, right click on it an see its properties (in the browser). what path does it say there?

try one more thing also, right click on the image anc choose "Show Picture". does the image appear???

Known is handfull, Unknown is worldfull
 
What does the source look like for the image once the page has rendered?
ca8msm:
It displays the icon for a missing image, a small red "x" inside two squares.
That isn't the HTML code - can you post the source of the page once it has rendered? (look at the View Source option in your browser).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
vbkris-

Good question! I started IE and pasted this into the address bar:


I got the "x" indicating a missing file. I right-clicked the "x" and the object DID have the proper address.

ca8msm-

Great question. The view/source option is greyed out when I attempt to display it. That is unusual.
 
The option is greyed out as you have navigated directly to the image. Navigate to the page, look at the View Source and paste the contents here for the relevant img tag.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
see if it makes a difference if you use a gif file. convert the jpg to gif and see if you can see it then..

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top