471,082 Members | 722 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,082 software developers and data experts.

Relitive or absolute path HELP

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

Apr 26 '06 #1
5 1677
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
"Michael" wrote:
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

Apr 26 '06 #2
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?

Apr 26 '06 #3
Choose View Source in the browser when it DOES work, and compare the
differences when you View Source when it DOESN'T work

Jeff

"Michael" <Mi*****@discussions.microsoft.com> wrote in message
news:CA**********************************@microsof t.com...
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
"Michael" wrote:
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

Apr 27 '06 #4
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)
"Michael" <Mi*****@discussions.microsoft.com> wrote in message
news:CA**********************************@microsof t.com...
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
"Michael" wrote:
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

Apr 27 '06 #5
Hi Bruce,
Thanks to everyone that replied. I will try the solutions tonight when I get
home.
Thanks Mike
"bruce barker (sqlwork.com)" wrote:
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)
"Michael" <Mi*****@discussions.microsoft.com> wrote in message
news:CA**********************************@microsof t.com...
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
"Michael" wrote:
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


Apr 27 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Peter Taurins | last post: by
4 posts views Thread by dchaffin | last post: by
3 posts views Thread by rajuvk | last post: by
2 posts views Thread by Markus Doering | last post: by
9 posts views Thread by Stuart | last post: by
7 posts views Thread by Rizaan Jappie | last post: by
6 posts views Thread by Jon Slaughter | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.