Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

In my ASP.NET projects, I use relative paths.

<a href="../images/blue.gif" alt="">Example</a>

This works for me because I code and test my websites locally, then once they are ready to implement, I FTP them over to our remote server.

 

Visual Studio hates this, though! It refuses to compile my web application because anything with "../" gets lost. It wants the fully qualified name:

 

"C:\Documents and Settings\jpool\My Documents\Web Projects\Website500\images\blue.gif"

 

That may work fine for testing my application at my desk, but whenever I FTP it to the server, that obviously won't work.

 

Is there a way I can slap Visual Studio so that it will understand the basics that were derived years ago? Maybe there is a setting somewhere burried under the Options menu?

Posted

PD is right that should work.

 

The tilda ("~") character should translate into the proper path at runtime; however for this to happen the path must be contained in a control with a

runat="server"

 

In your case the main <form> tag of the page should suffice. However, if you were using

<link href="~/Site.css" type="text/css" rel="stylesheet"></link>

you'd need to put that inside of a tag with runat="server"

 

<head runat="server" id="head1">
   <link href="~/Site.css" type="text/css" rel="stylesheet"></link>
</head>

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Posted

The root directory

 

PD raises another question: Does the tilde (~) map to the root directory or simply to one directory up?

 

The root directory of the project.

 

Good luck :cool:

Never trouble another for what you can do for yourself.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...