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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

maintaining links with asp

Status
Not open for further replies.

scroce

MIS
Nov 30, 2000
780
US
I've just inhereted an asp site with the following sample directory structure:

Root(Folder)
MyProject(Folder)
MainPage.asp
BigProducts.asp
EmailLinks.asp
etc.
SmallProducts(Folder)
SmallProd1.asp
SmallProd2.asp
etc.
EvenSmallerProducts(Folder)
EvenSmaller1.asp
EvenSmaller2.asp
etc.

Each of the pages uses EmailLinks.asp which automatically dumps email address queried from an access database into a nice formatted box on the page through the following code:

Response.Write &quot;<a href=EmailLinks.asp?emailid=&quot;

The problem is, all the files used to be organized under the MyProject(Folder). As the site grew, new smaller products were added under the MyProject(Folder) illustrated by SmallProducts(Folder).

The problem is now, the asp code:

Response.Write &quot;<a href=EmailLinks.asp?emailid=&quot;

will not work when it is called from anything on the SmallProd(Folder) level or EvenSmaller(Folder) level because of the directory structure - the path is not right.

A workaround, I suppose, would be to put a copy of EmailLinks.asp into every subdirectory, but that seems inherently dumb. Another would be to put everything back at the MyProject(Folder) level, but I'd like to avoid that for the sake of clean organization.

These files have to be able to see EmailLinks.asp, even if their at different levels in the root directory. How do I get this to work? Possibly something with Server.mappath?

sc

How much water would there be in the ocean if it weren't for sponges?
 
To 'break out & up' from your directory to the upper level, here is the syntax:

Response.Write &quot;<a href=../EmailLinks.asp?emailid=&quot;

and from the evenSmaller... directory, it would be:

Response.Write &quot;<a href=../../EmailLinks.asp?emailid=&quot;

so that you use two dots (..) and then a slash (/) to get up a level -- (../)

good luck! :)
Paul Prewett

 
i've tried that, and here's why it doesn't work.

If you change the relative path in this line:

Response.Write &quot;<a href=EmailLinks.asp?emailid=&quot;

to something like

Response.Write &quot;<a href=../../EmailLinks.asp?emailid=&quot;

then the asp code will always generate that html, which will not work when the user access BigProducts.asp, for example. BigProducts.asp is on the same level as EmailLinks.asp, so &quot;file not found&quot; error message is generated whenever someone access this page, because the incuded file is on the same level, not two levels up. It's looking in the wrong place.

This code will work fine when someone opens something from the EvenSmaller(Folder).

Is there anything in ASP that makes it intelligent enough to look for files at different levels?
How much water would there be in the ocean if it weren't for sponges?
 
maybe i'll just have to put an include folder in every subdirectory i create.

It just seems like I shouldn't have to do this. How much water would there be in the ocean if it weren't for sponges?
 
Why don't you try using a server.mappath, then strip out the Drive and root folder, replacing it with your URL?

Ex:
dim path
path = Server.MapPath(&quot;EmailLinks.asp&quot;)

path = Replace(path,&quot;C:\Inetpub\wwwroot&quot;,&quot;path = Replace(path,&quot;\&quot;,&quot;/&quot;) 'to get the slashes the right way

Response.write path

The output of this would be something like

This should work for you... I haven't been able to test it but it seems right.

good luck
leo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top