webMunkee Posted January 19, 2004 Posted January 19, 2004 Hi all, first time poster here in need of help. I've searched for the answer to this question with out any luck. I am having severe difficulties with relative paths in .NET. I have a number of user controls that build the header, footer, navigation etc. on my pages. I need to have the elements of those UC's use relative paths for images, and links. Since .NET virtually forces you to create your web project in a sub directory of the localhost, I am not sure where to go from here. On the live webserver the site is at the root so an image is located at src="/images/myImage.gif" but locally my relative path is src="/myProjectName/Images/myImage.gif" I have been coding to suit the Live server, so none of images display when viewing pages locally, I can longer do this as development is cranking up and I need to work correctly locally. I tried putting a variable in front of my paths and using a the web config to set the variable. locally the variable myPath = "/myProjectName/" on the server the myPath = "". This fixed it when the pages ran but my pages were unable to go into design view at the point for editing. It also causes headaches for the non-coders that get into the pages via Dreamweaver. Does anyone know of a simple solution to this dilema? I do not remeber having these issues in Visual InterDev. Either that or that ball to head in little league 20 years ago really did do damage. :( Thanks in advnace for any help webMunkee Quote
Administrators PlausiblyDamp Posted January 19, 2004 Administrators Posted January 19, 2004 A possible problem is that user controls resolve urls relative to themselves (the ascx file) rather than the page that contains them. In code you could use something along the lines of Page.ResolveUrl(relative url here) this will resolve the url relative to it's containing page. If you have user controls containing other user controls then this no longer works.... Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
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.