joe_pool_is Posted May 19, 2008 Posted May 19, 2008 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? Quote Avoid Sears Home Improvement
Administrators PlausiblyDamp Posted May 19, 2008 Administrators Posted May 19, 2008 Is images off the root folder? If so you should be able to use a path of "~/images/blue.gif" as an example. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Nate Bross Posted May 19, 2008 Posted May 19, 2008 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> Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
joe_pool_is Posted May 19, 2008 Author Posted May 19, 2008 Thanks! That does a good job. PD raises another question: Does the tilde (~) map to the root directory or simply to one directory up? Quote Avoid Sears Home Improvement
MrPaul Posted May 19, 2008 Posted May 19, 2008 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: Quote Never trouble another for what you can do for yourself.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.