Visual Studio 2005 and HTML

joe_pool_is

Contributor
Joined
Jan 18, 2004
Messages
507
Location
Longview, TX [USA]
In my ASP.NET projects, I use relative paths.
Code:
<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?
 
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
Code:
runat="server"

In your case the main <form> tag of the page should suffice. However, if you were using
Code:
<link href="~/Site.css" type="text/css" rel="stylesheet"></link>
you'd need to put that inside of a tag with runat="server"

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