Board index » Web Programming » Relitive or absolute path HELP

Relitive or absolute path HELP

Web Programming265
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


-
 

Re:Relitive or absolute path HELP

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:



Quote
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



-

Re:Relitive or absolute path HELP

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?



-

Re:Relitive or absolute path HELP

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" <Michael@discussions.microsoft.com>wrote in message

Quote
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

>





-

Re:Relitive or absolute path HELP

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" <Michael@discussions.microsoft.com>wrote in message

Quote
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

>





-

Re:Relitive or absolute path HELP

Hi Bruce,

Thanks to everyone that replied. I will try the solutions tonight when I get

home.

Thanks Mike





"bruce barker (sqlwork.com)" wrote:



Quote
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" <Michael@discussions.microsoft.com>wrote in message

news:CABFF4AE-9967-433D-99CF-AB685FF21277@microsoft.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

>>







-