image.src

J

Jeff

Hey

asp.net 2.0

I have a webpage which generate thumbnail images. In another webpage I want
to display these images...
I tryed using this solution:
<img ID="photo" src="../../images/helloworld.jpeg"/>
But this gives this error:
File '../../images/helloworld.jpeg' was not found

The file helloworld.jpeg exist in the ../../images/ folder.....

If I in solution explorer right click and choose "Add Existing Item" and add
this image, then this works.... but the images are generated dynamically in
runtime so adding them to the project isn't a good solution

Any ideas what I should do to solve this?

Jeff
 
R

Riki

Jeff said:
Hey

asp.net 2.0

I have a webpage which generate thumbnail images. In another webpage
I want to display these images...
I tryed using this solution:
<img ID="photo" src="../../images/helloworld.jpeg"/>
But this gives this error:
File '../../images/helloworld.jpeg' was not found

The file helloworld.jpeg exist in the ../../images/ folder.....

If I in solution explorer right click and choose "Add Existing Item"
and add this image, then this works.... but the images are generated
dynamically in runtime so adding them to the project isn't a good
solution

If the images are generated dynamically in runtime, why are you
refering to them statically at compile time?

I suggest either:
1) adding a "dummy" image that is replaced at runtime with the real image
or
2) removing the static reference and setting the src property at runtime
 
R

Riki

Jeff said:
Hey

asp.net 2.0

I have a webpage which generate thumbnail images. In another webpage
I want to display these images...
I tryed using this solution:
<img ID="photo" src="../../images/helloworld.jpeg"/>
But this gives this error:
File '../../images/helloworld.jpeg' was not found

The file helloworld.jpeg exist in the ../../images/ folder.....

If I in solution explorer right click and choose "Add Existing Item"
and add this image, then this works.... but the images are generated
dynamically in runtime so adding them to the project isn't a good
solution

If the images are generated dynamically in runtime, why are you
refering to them statically at compile time?

I suggest either:
1) adding a "dummy" image that is replaced at runtime with the real image
or
2) removing the static reference and setting the src property at runtime
 
J

Jeff

Riki said:
If the images are generated dynamically in runtime, why are you
refering to them statically at compile time?

I suggest either:
1) adding a "dummy" image that is replaced at runtime with the real image
or
2) removing the static reference and setting the src property at runtime

Hmm the code I mentioned above was just an example, I've also tryed this
way:
<img ID="photo" src= "<%# Eval("File") %>"/> but it gives the same error....

I wonder about your 2. suggestion:
This list of images are displayed in a Repeater control. Is it a good
solution to use the rptInbox_ItemDataBound (my repeaer control's ID =
rptInbox) event do dynamically add the image to the webpage or are there
some other event's which suits better?... Sorry if my questions sounds odd,
but I'm a newbie...

Jeff
 
H

Hans Kesting

Hey
asp.net 2.0

I have a webpage which generate thumbnail images. In another webpage I want
to display these images...
I tryed using this solution:
<img ID="photo" src="../../images/helloworld.jpeg"/>
But this gives this error:
File '../../images/helloworld.jpeg' was not found

The file helloworld.jpeg exist in the ../../images/ folder.....

If I in solution explorer right click and choose "Add Existing Item" and add
this image, then this works.... but the images are generated dynamically in
runtime so adding them to the project isn't a good solution

Any ideas what I should do to solve this?

Jeff

I take it the *browser* gives that errormessage?
What is in the html that the browser received (do a "view source").
Does the "src" still point to the directory you think it should point
at?
Reason: if the "src" attribute is processed by the asp.net environment
(as it will be when you add a runat=server attribute), then it might be
changed. When this code is in an ascx, the path is taken to be relative
to the *ascx*, not relative to the aspx it ends up in.
When this is the case, you could use "webapp-root-relative" paths, by
starting with a "~" (~/images/helloworld.jpeg). This will work wherever
the application is installed: //localhost/theApp/Web or
//www.somesite.com

Hans Kesting
 
R

Riki

Jeff said:
Hmm the code I mentioned above was just an example, I've also tryed
this way:
<img ID="photo" src= "<%# Eval("File") %>"/> but it gives the same
error....

This should work, but you should fix the outer quotes into single quotes:
I wonder about your 2. suggestion:
This list of images are displayed in a Repeater control. Is it a good
solution to use the rptInbox_ItemDataBound (my repeaer control's ID =
rptInbox) event do dynamically add the image to the webpage or are
there some other event's which suits better?... Sorry if my questions
sounds odd, but I'm a newbie...

We all were newbies once... so that's no problem.
ItemDataBound is ok, but the Eval method above is the preferred one.

See also Hans' remark.
 
J

Jeff

Thank you


Riki said:
This should work, but you should fix the outer quotes into single quotes:


We all were newbies once... so that's no problem.
ItemDataBound is ok, but the Eval method above is the preferred one.

See also Hans' remark.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top