Relitive or absolute path HELP

G

Guest

Hi,
For a home project I'm working on, I'm trying to get access to images within
the web path, but the images don't show and I thing its because of the paths.
Here is the dir structure:
wwwroot
App_Code
UserControls
ProductPictures
Now, the problem is that I've created a User control thats in the
UserControl directory. The images are in the ProductPictures dir. I can't
seem to use:
ProductPictures/imagename.gif
or
.../ProductPictures/imagename.gif
I've also tried:
~/ProductPictures/imagename.gif
none of these work, I think because the user control is not in the wwwroot
dir. Would that be correct? If so, How can I get to that path from the
UserControl dir. I'm hoping I don't have to use the absolute path because
that would cause alot of changes before putting it on the web server. Any
suggestions? Thanks for any suggestions.
Michael
 
G

Guest

Hi Again,
I've been doing some more testing and I have found a few things. To start
off with let me post the code:
**User control**
<asp:Repeater ID="SpecialsRepeater" runat="server"
DataSourceID="SpecialsDataSource">
<ItemTemplate >
<asp:ImageButton ID="ImageButton1" runat="server"

ImageUrl='../ProductPictures/<%#Eval("Image1FileName")#%>'

PostBackUrl='../Product.aspx?ProductID=<%#Eval("ProductID")%>'/>

</ItemTemplate>
</asp:Repeater>
If I removed the Eval and put the imagename in manually, it seems to work,
but I put it back, the system can't seem to find the images again. I've tried
many, many combos for the path and nothing seems to work right when I use the
eval function.
Does anyone have any ideas. Thanks
Michael
 
D

Darrin

When you use the Eval function and view the source of the resulting
page, what does the path look like? Is it off by a directory? Is the
corrrect file name there?
 
J

Jeff Dillon

Choose View Source in the browser when it DOES work, and compare the
differences when you View Source when it DOESN'T work

Jeff
 
B

bruce barker \(sqlwork.com\)

here is your coding error:

ImageUrl='../ProductPictures/<%#Eval("Image1FileName")#%>'

you can not imbed <%# %> (binding value) inside a property value string. the
value must start with a "<%#" and end with a "#%>" or it will not be
processed. try:

ImageUrl='<%# Format("Image1FileName") %>'

-- bruce (sqlwork.com)
 
G

Guest

Hi Bruce,
Thanks to everyone that replied. I will try the solutions tonight when I get
home.
Thanks Mike
 

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,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top